Upgrade V8 to version 4.9.385.28
https://chromium.googlesource.com/v8/v8/+/4.9.385.28
FPIIM-449
Change-Id: I4b2e74289d4bf3667f2f3dc8aa2e541f63e26eb4
diff --git a/src/ic/ic.cc b/src/ic/ic.cc
index 0707536..73ac666 100644
--- a/src/ic/ic.cc
+++ b/src/ic/ic.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "src/v8.h"
+#include "src/ic/ic.h"
#include "src/accessors.h"
#include "src/api.h"
@@ -11,11 +11,14 @@
#include "src/codegen.h"
#include "src/conversions.h"
#include "src/execution.h"
+#include "src/frames-inl.h"
#include "src/ic/call-optimization.h"
#include "src/ic/handler-compiler.h"
#include "src/ic/ic-inl.h"
#include "src/ic/ic-compiler.h"
#include "src/ic/stub-cache.h"
+#include "src/isolate-inl.h"
+#include "src/macro-assembler.h"
#include "src/prototype.h"
#include "src/runtime/runtime.h"
@@ -44,9 +47,6 @@
// these cases fall through to the unreachable code below.
case DEBUG_STUB:
break;
- // Type-vector-based ICs resolve state to one of the above.
- case DEFAULT:
- break;
}
UNREACHABLE();
return 0;
@@ -89,6 +89,7 @@
void IC::TraceIC(const char* type, Handle<Object> name) {
if (FLAG_trace_ic) {
+ if (AddressIsDeoptimizedCode()) return;
State new_state =
UseVector() ? nexus()->StateFromFeedback() : raw_target()->ic_state();
TraceIC(type, name, state(), new_state);
@@ -116,11 +117,11 @@
stdout, true);
}
- ExtraICState extra_state = new_target->extra_ic_state();
const char* modifier = "";
if (new_target->kind() == Code::KEYED_STORE_IC) {
- modifier = GetTransitionMarkModifier(
- KeyedStoreIC::GetKeyedAccessStoreMode(extra_state));
+ KeyedAccessStoreMode mode =
+ casted_nexus<KeyedStoreICNexus>()->GetKeyedAccessStoreMode();
+ modifier = GetTransitionMarkModifier(mode);
}
PrintF(" (%c->%c%s) ", TransitionMarkFromState(old_state),
TransitionMarkFromState(new_state), modifier);
@@ -138,20 +139,20 @@
#define TRACE_IC(type, name) TraceIC(type, name)
-IC::IC(FrameDepth depth, Isolate* isolate, FeedbackNexus* nexus,
- bool for_queries_only)
+IC::IC(FrameDepth depth, Isolate* isolate, FeedbackNexus* nexus)
: isolate_(isolate),
target_set_(false),
+ vector_set_(false),
target_maps_set_(false),
nexus_(nexus) {
// To improve the performance of the (much used) IC code, we unfold a few
// levels of the stack frame iteration code. This yields a ~35% speedup when
// running DeltaBlue and a ~25% speedup of gbemu with the '--nouse-ic' flag.
const Address entry = Isolate::c_entry_fp(isolate->thread_local_top());
- Address constant_pool = NULL;
- if (FLAG_enable_ool_constant_pool) {
- constant_pool =
- Memory::Address_at(entry + ExitFrameConstants::kConstantPoolOffset);
+ Address* constant_pool = NULL;
+ if (FLAG_enable_embedded_constant_pool) {
+ constant_pool = reinterpret_cast<Address*>(
+ entry + ExitFrameConstants::kConstantPoolOffset);
}
Address* pc_address =
reinterpret_cast<Address*>(entry + ExitFrameConstants::kCallerPCOffset);
@@ -160,9 +161,9 @@
// StubFailureTrampoline, we need to look one frame further down the stack to
// find the frame pointer and the return address stack slot.
if (depth == EXTRA_CALL_FRAME) {
- if (FLAG_enable_ool_constant_pool) {
- constant_pool =
- Memory::Address_at(fp + StandardFrameConstants::kConstantPoolOffset);
+ if (FLAG_enable_embedded_constant_pool) {
+ constant_pool = reinterpret_cast<Address*>(
+ fp + StandardFrameConstants::kConstantPoolOffset);
}
const int kCallerPCOffset = StandardFrameConstants::kCallerPCOffset;
pc_address = reinterpret_cast<Address*>(fp + kCallerPCOffset);
@@ -175,16 +176,13 @@
DCHECK(fp == frame->fp() && pc_address == frame->pc_address());
#endif
fp_ = fp;
- if (FLAG_enable_ool_constant_pool) {
- raw_constant_pool_ = handle(
- ConstantPoolArray::cast(reinterpret_cast<Object*>(constant_pool)),
- isolate);
+ if (FLAG_enable_embedded_constant_pool) {
+ constant_pool_address_ = constant_pool;
}
pc_address_ = StackFrame::ResolveReturnAddressLocation(pc_address);
target_ = handle(raw_target(), isolate);
kind_ = target_->kind();
- state_ = (!for_queries_only && UseVector()) ? nexus->StateFromFeedback()
- : target_->ic_state();
+ state_ = UseVector() ? nexus->StateFromFeedback() : target_->ic_state();
old_state_ = state_;
extra_ic_state_ = target_->extra_ic_state();
}
@@ -196,6 +194,11 @@
// corresponding to the frame.
StackFrameIterator it(isolate());
while (it.frame()->fp() != this->fp()) it.Advance();
+ if (FLAG_ignition && it.frame()->type() == StackFrame::STUB) {
+ // Advance over bytecode handler frame.
+ // TODO(rmcilroy): Remove this once bytecode handlers don't need a frame.
+ it.Advance();
+ }
JavaScriptFrame* frame = JavaScriptFrame::cast(it.frame());
// Find the function on the stack and both the active code for the
// function and the original code.
@@ -212,13 +215,10 @@
}
-Code* IC::GetOriginalCode() const {
- HandleScope scope(isolate());
- Handle<SharedFunctionInfo> shared(GetSharedFunctionInfo(), isolate());
- DCHECK(Debug::HasDebugInfo(shared));
- Code* original_code = Debug::GetDebugInfo(shared)->original_code();
- DCHECK(original_code->IsCode());
- return original_code;
+bool IC::AddressIsOptimizedCode() const {
+ Code* host =
+ isolate()->inner_pointer_to_code_cache()->GetCacheEntry(address())->code;
+ return host->kind() == Code::OPTIMIZED_FUNCTION;
}
@@ -241,12 +241,12 @@
case LookupIterator::ACCESS_CHECK:
// PropertyHandlerCompiler::CheckPrototypes() knows how to emit
// access checks for global proxies.
- if (it->GetHolder<JSObject>()->IsJSGlobalProxy() &&
- it->HasAccess(v8::ACCESS_GET)) {
+ if (it->GetHolder<JSObject>()->IsJSGlobalProxy() && it->HasAccess()) {
break;
}
return;
case LookupIterator::ACCESSOR:
+ case LookupIterator::INTEGER_INDEXED_EXOTIC:
case LookupIterator::DATA:
return;
}
@@ -257,11 +257,10 @@
bool IC::TryRemoveInvalidPrototypeDependentStub(Handle<Object> receiver,
Handle<String> name) {
if (!IsNameCompatibleWithPrototypeFailure(name)) return false;
- Handle<Map> receiver_map = TypeToMap(*receiver_type(), isolate());
if (UseVector()) {
- maybe_handler_ = nexus()->FindHandlerForMap(receiver_map);
+ maybe_handler_ = nexus()->FindHandlerForMap(receiver_map());
} else {
- maybe_handler_ = target()->FindHandlerForMap(*receiver_map);
+ maybe_handler_ = target()->FindHandlerForMap(*receiver_map());
}
// The current map wasn't handled yet. There's no reason to stay monomorphic,
@@ -270,21 +269,17 @@
// TODO(verwaest): Check if the current map is actually what the old map
// would transition to.
if (maybe_handler_.is_null()) {
- if (!receiver_map->IsJSObjectMap()) return false;
+ if (!receiver_map()->IsJSObjectMap()) return false;
Map* first_map = FirstTargetMap();
if (first_map == NULL) return false;
Handle<Map> old_map(first_map);
if (old_map->is_deprecated()) return true;
- if (IsMoreGeneralElementsKindTransition(old_map->elements_kind(),
- receiver_map->elements_kind())) {
- return true;
- }
- return false;
+ return IsMoreGeneralElementsKindTransition(old_map->elements_kind(),
+ receiver_map()->elements_kind());
}
CacheHolderFlag flag;
- Handle<Map> ic_holder_map(
- GetICCacheHolder(*receiver_type(), isolate(), &flag));
+ Handle<Map> ic_holder_map(GetICCacheHolder(receiver_map(), isolate(), &flag));
DCHECK(flag != kCacheOnReceiver || receiver->IsJSObject());
DCHECK(flag != kCacheOnPrototype || !receiver->IsJSReceiver());
@@ -297,13 +292,12 @@
}
}
- if (receiver->IsGlobalObject()) {
- Handle<GlobalObject> global = Handle<GlobalObject>::cast(receiver);
+ if (receiver->IsJSGlobalObject()) {
+ Handle<JSGlobalObject> global = Handle<JSGlobalObject>::cast(receiver);
LookupIterator it(global, name, LookupIterator::OWN_SKIP_INTERCEPTOR);
if (it.state() == LookupIterator::ACCESS_CHECK) return false;
if (!it.IsFound()) return false;
- Handle<PropertyCell> cell = it.GetPropertyCell();
- return cell->type()->IsConstant();
+ return it.property_details().cell_type() == PropertyCellType::kConstant;
}
return true;
@@ -324,7 +318,7 @@
void IC::UpdateState(Handle<Object> receiver, Handle<Object> name) {
- update_receiver_type(receiver);
+ update_receiver_map(receiver);
if (!name->IsString()) return;
if (state() != MONOMORPHIC && state() != POLYMORPHIC) return;
if (receiver->IsUndefined() || receiver->IsNull()) return;
@@ -337,29 +331,20 @@
MarkPrototypeFailure(name);
return;
}
-
- // The builtins object is special. It only changes when JavaScript
- // builtins are loaded lazily. It is important to keep inline
- // caches for the builtins object monomorphic. Therefore, if we get
- // an inline cache miss for the builtins object after lazily loading
- // JavaScript builtins, we return uninitialized as the state to
- // force the inline cache back to monomorphic state.
- if (receiver->IsJSBuiltinsObject()) state_ = PREMONOMORPHIC;
}
-MaybeHandle<Object> IC::TypeError(const char* type, Handle<Object> object,
- Handle<Object> key) {
+MaybeHandle<Object> IC::TypeError(MessageTemplate::Template index,
+ Handle<Object> object, Handle<Object> key) {
HandleScope scope(isolate());
- Handle<Object> args[2] = {key, object};
- THROW_NEW_ERROR(isolate(), NewTypeError(type, HandleVector(args, 2)), Object);
+ THROW_NEW_ERROR(isolate(), NewTypeError(index, key, object), Object);
}
-MaybeHandle<Object> IC::ReferenceError(const char* type, Handle<Name> name) {
+MaybeHandle<Object> IC::ReferenceError(Handle<Name> name) {
HandleScope scope(isolate());
- THROW_NEW_ERROR(isolate(), NewReferenceError(type, HandleVector(&name, 1)),
- Object);
+ THROW_NEW_ERROR(
+ isolate(), NewReferenceError(MessageTemplate::kNotDefined, name), Object);
}
@@ -394,7 +379,6 @@
break;
case PROTOTYPE_FAILURE:
case DEBUG_STUB:
- case DEFAULT:
UNREACHABLE();
}
}
@@ -431,19 +415,9 @@
// static
-void IC::OnTypeFeedbackChanged(Isolate* isolate, Code* host,
- TypeFeedbackVector* vector, State old_state,
- State new_state) {
+void IC::OnTypeFeedbackChanged(Isolate* isolate, Code* host) {
if (host->kind() != Code::FUNCTION) return;
- if (FLAG_type_info_threshold > 0) {
- int polymorphic_delta = 0; // "Polymorphic" here includes monomorphic.
- int generic_delta = 0; // "Generic" here includes megamorphic.
- ComputeTypeInfoCountDelta(old_state, new_state, &polymorphic_delta,
- &generic_delta);
- vector->change_ic_with_type_info_count(polymorphic_delta);
- vector->change_ic_generic_count(generic_delta);
- }
TypeFeedbackInfo* info = TypeFeedbackInfo::cast(host->type_feedback_info());
info->change_own_type_change_checksum();
host->set_profiler_ticks(0);
@@ -474,8 +448,7 @@
}
-void IC::Clear(Isolate* isolate, Address address,
- ConstantPoolArray* constant_pool) {
+void IC::Clear(Isolate* isolate, Address address, Address constant_pool) {
Code* target = GetTargetAtAddress(address, constant_pool);
// Don't clear debug break inline cache as it will remove the break point.
@@ -483,15 +456,10 @@
switch (target->kind()) {
case Code::LOAD_IC:
- if (FLAG_vector_ics) return;
- return LoadIC::Clear(isolate, address, target, constant_pool);
case Code::KEYED_LOAD_IC:
- if (FLAG_vector_ics) return;
- return KeyedLoadIC::Clear(isolate, address, target, constant_pool);
case Code::STORE_IC:
- return StoreIC::Clear(isolate, address, target, constant_pool);
case Code::KEYED_STORE_IC:
- return KeyedStoreIC::Clear(isolate, address, target, constant_pool);
+ return;
case Code::COMPARE_IC:
return CompareIC::Clear(isolate, address, target, constant_pool);
case Code::COMPARE_NIL_IC:
@@ -508,26 +476,13 @@
}
-void KeyedLoadIC::Clear(Isolate* isolate, Address address, Code* target,
- ConstantPoolArray* constant_pool) {
- DCHECK(!FLAG_vector_ics);
- if (IsCleared(target)) return;
-
- // Make sure to also clear the map used in inline fast cases. If we
- // do not clear these maps, cached code can keep objects alive
- // through the embedded maps.
- SetTargetAtAddress(address, *pre_monomorphic_stub(isolate), constant_pool);
-}
-
-
void KeyedLoadIC::Clear(Isolate* isolate, Code* host, KeyedLoadICNexus* nexus) {
if (IsCleared(nexus)) return;
// Make sure to also clear the map used in inline fast cases. If we
// do not clear these maps, cached code can keep objects alive
// through the embedded maps.
- State state = nexus->StateFromFeedback();
nexus->ConfigurePremonomorphic();
- OnTypeFeedbackChanged(isolate, host, nexus->vector(), state, PREMONOMORPHIC);
+ OnTypeFeedbackChanged(isolate, host);
}
@@ -539,31 +494,20 @@
if (state != UNINITIALIZED && !feedback->IsAllocationSite()) {
nexus->ConfigureUninitialized();
// The change in state must be processed.
- OnTypeFeedbackChanged(isolate, host, nexus->vector(), state, UNINITIALIZED);
+ OnTypeFeedbackChanged(isolate, host);
}
}
-void LoadIC::Clear(Isolate* isolate, Address address, Code* target,
- ConstantPoolArray* constant_pool) {
- DCHECK(!FLAG_vector_ics);
- if (IsCleared(target)) return;
- Code* code = PropertyICCompiler::FindPreMonomorphic(isolate, Code::LOAD_IC,
- target->extra_ic_state());
- SetTargetAtAddress(address, code, constant_pool);
-}
-
-
void LoadIC::Clear(Isolate* isolate, Code* host, LoadICNexus* nexus) {
if (IsCleared(nexus)) return;
- State state = nexus->StateFromFeedback();
nexus->ConfigurePremonomorphic();
- OnTypeFeedbackChanged(isolate, host, nexus->vector(), state, PREMONOMORPHIC);
+ OnTypeFeedbackChanged(isolate, host);
}
void StoreIC::Clear(Isolate* isolate, Address address, Code* target,
- ConstantPoolArray* constant_pool) {
+ Address constant_pool) {
if (IsCleared(target)) return;
Code* code = PropertyICCompiler::FindPreMonomorphic(isolate, Code::STORE_IC,
target->extra_ic_state());
@@ -571,34 +515,52 @@
}
+void StoreIC::Clear(Isolate* isolate, Code* host, StoreICNexus* nexus) {
+ if (IsCleared(nexus)) return;
+ nexus->ConfigurePremonomorphic();
+ OnTypeFeedbackChanged(isolate, host);
+}
+
+
void KeyedStoreIC::Clear(Isolate* isolate, Address address, Code* target,
- ConstantPoolArray* constant_pool) {
+ Address constant_pool) {
if (IsCleared(target)) return;
- SetTargetAtAddress(
- address, *pre_monomorphic_stub(
- isolate, StoreIC::GetStrictMode(target->extra_ic_state())),
- constant_pool);
+ Handle<Code> code = pre_monomorphic_stub(
+ isolate, StoreICState::GetLanguageMode(target->extra_ic_state()));
+ SetTargetAtAddress(address, *code, constant_pool);
+}
+
+
+void KeyedStoreIC::Clear(Isolate* isolate, Code* host,
+ KeyedStoreICNexus* nexus) {
+ if (IsCleared(nexus)) return;
+ nexus->ConfigurePremonomorphic();
+ OnTypeFeedbackChanged(isolate, host);
}
void CompareIC::Clear(Isolate* isolate, Address address, Code* target,
- ConstantPoolArray* constant_pool) {
+ Address constant_pool) {
DCHECK(CodeStub::GetMajorKey(target) == CodeStub::CompareIC);
CompareICStub stub(target->stub_key(), isolate);
// Only clear CompareICs that can retain objects.
- if (stub.state() != CompareICState::KNOWN_OBJECT) return;
- SetTargetAtAddress(address, GetRawUninitialized(isolate, stub.op()),
+ if (stub.state() != CompareICState::KNOWN_RECEIVER) return;
+ SetTargetAtAddress(address,
+ GetRawUninitialized(isolate, stub.op(), stub.strength()),
constant_pool);
- PatchInlinedSmiCode(address, DISABLE_INLINED_SMI_CHECK);
+ PatchInlinedSmiCode(isolate, address, DISABLE_INLINED_SMI_CHECK);
}
// static
-Handle<Code> KeyedLoadIC::generic_stub(Isolate* isolate) {
+Handle<Code> KeyedLoadIC::ChooseMegamorphicStub(Isolate* isolate,
+ ExtraICState extra_state) {
if (FLAG_compiled_keyed_generic_loads) {
- return KeyedLoadGenericStub(isolate).GetCode();
+ return KeyedLoadGenericStub(isolate, LoadICState(extra_state)).GetCode();
} else {
- return isolate->builtins()->KeyedLoadIC_Generic();
+ return is_strong(LoadICState::GetLanguageMode(extra_state))
+ ? isolate->builtins()->KeyedLoadIC_Megamorphic_Strong()
+ : isolate->builtins()->KeyedLoadIC_Megamorphic();
}
}
@@ -614,64 +576,75 @@
void IC::ConfigureVectorState(IC::State new_state) {
DCHECK(UseVector());
- if (kind() == Code::LOAD_IC) {
- LoadICNexus* nexus = casted_nexus<LoadICNexus>();
- if (new_state == PREMONOMORPHIC) {
- nexus->ConfigurePremonomorphic();
- } else if (new_state == MEGAMORPHIC) {
- nexus->ConfigureMegamorphic();
- } else {
- UNREACHABLE();
- }
- } else if (kind() == Code::KEYED_LOAD_IC) {
- KeyedLoadICNexus* nexus = casted_nexus<KeyedLoadICNexus>();
- if (new_state == GENERIC) {
- nexus->ConfigureGeneric();
- } else if (new_state == PREMONOMORPHIC) {
- nexus->ConfigurePremonomorphic();
- } else {
- UNREACHABLE();
- }
+ if (new_state == PREMONOMORPHIC) {
+ nexus()->ConfigurePremonomorphic();
+ } else if (new_state == MEGAMORPHIC) {
+ nexus()->ConfigureMegamorphic();
} else {
UNREACHABLE();
}
- OnTypeFeedbackChanged(isolate(), get_host(), *vector(), saved_state(),
- new_state);
+ vector_set_ = true;
+ OnTypeFeedbackChanged(isolate(), get_host());
}
-void IC::ConfigureVectorState(Handle<Name> name, Handle<HeapType> type,
+void IC::ConfigureVectorState(Handle<Name> name, Handle<Map> map,
Handle<Code> handler) {
DCHECK(UseVector());
if (kind() == Code::LOAD_IC) {
LoadICNexus* nexus = casted_nexus<LoadICNexus>();
- nexus->ConfigureMonomorphic(type, handler);
- } else {
- DCHECK(kind() == Code::KEYED_LOAD_IC);
+ nexus->ConfigureMonomorphic(map, handler);
+ } else if (kind() == Code::KEYED_LOAD_IC) {
KeyedLoadICNexus* nexus = casted_nexus<KeyedLoadICNexus>();
- nexus->ConfigureMonomorphic(name, type, handler);
+ nexus->ConfigureMonomorphic(name, map, handler);
+ } else if (kind() == Code::STORE_IC) {
+ StoreICNexus* nexus = casted_nexus<StoreICNexus>();
+ nexus->ConfigureMonomorphic(map, handler);
+ } else {
+ DCHECK(kind() == Code::KEYED_STORE_IC);
+ KeyedStoreICNexus* nexus = casted_nexus<KeyedStoreICNexus>();
+ nexus->ConfigureMonomorphic(name, map, handler);
}
- OnTypeFeedbackChanged(isolate(), get_host(), *vector(), saved_state(),
- MONOMORPHIC);
+ vector_set_ = true;
+ OnTypeFeedbackChanged(isolate(), get_host());
}
-void IC::ConfigureVectorState(Handle<Name> name, TypeHandleList* types,
+void IC::ConfigureVectorState(Handle<Name> name, MapHandleList* maps,
CodeHandleList* handlers) {
DCHECK(UseVector());
if (kind() == Code::LOAD_IC) {
LoadICNexus* nexus = casted_nexus<LoadICNexus>();
- nexus->ConfigurePolymorphic(types, handlers);
- } else {
- DCHECK(kind() == Code::KEYED_LOAD_IC);
+ nexus->ConfigurePolymorphic(maps, handlers);
+ } else if (kind() == Code::KEYED_LOAD_IC) {
KeyedLoadICNexus* nexus = casted_nexus<KeyedLoadICNexus>();
- nexus->ConfigurePolymorphic(name, types, handlers);
+ nexus->ConfigurePolymorphic(name, maps, handlers);
+ } else if (kind() == Code::STORE_IC) {
+ StoreICNexus* nexus = casted_nexus<StoreICNexus>();
+ nexus->ConfigurePolymorphic(maps, handlers);
+ } else {
+ DCHECK(kind() == Code::KEYED_STORE_IC);
+ KeyedStoreICNexus* nexus = casted_nexus<KeyedStoreICNexus>();
+ nexus->ConfigurePolymorphic(name, maps, handlers);
}
- OnTypeFeedbackChanged(isolate(), get_host(), *vector(), saved_state(),
- POLYMORPHIC);
+ vector_set_ = true;
+ OnTypeFeedbackChanged(isolate(), get_host());
+}
+
+
+void IC::ConfigureVectorState(MapHandleList* maps,
+ MapHandleList* transitioned_maps,
+ CodeHandleList* handlers) {
+ DCHECK(UseVector());
+ DCHECK(kind() == Code::KEYED_STORE_IC);
+ KeyedStoreICNexus* nexus = casted_nexus<KeyedStoreICNexus>();
+ nexus->ConfigurePolymorphic(maps, transitioned_maps, handlers);
+
+ vector_set_ = true;
+ OnTypeFeedbackChanged(isolate(), get_host());
}
@@ -679,7 +652,7 @@
// If the object is undefined or null it's illegal to try to get any
// of its properties; throw a TypeError in that case.
if (object->IsUndefined() || object->IsNull()) {
- return TypeError("non_object_property_load", object, name);
+ return TypeError(MessageTemplate::kNonObjectPropertyLoad, object, name);
}
// Check if the name is trivially convertible to an index and get
@@ -688,39 +661,44 @@
if (kind() == Code::KEYED_LOAD_IC && name->AsArrayIndex(&index)) {
// Rewrite to the generic keyed load stub.
if (FLAG_use_ic) {
- if (UseVector()) {
- ConfigureVectorState(GENERIC);
- } else {
- set_target(*KeyedLoadIC::generic_stub(isolate()));
- }
+ DCHECK(UseVector());
+ ConfigureVectorState(MEGAMORPHIC);
TRACE_IC("LoadIC", name);
TRACE_GENERIC_IC(isolate(), "LoadIC", "name as array index");
}
Handle<Object> result;
ASSIGN_RETURN_ON_EXCEPTION(
isolate(), result,
- Runtime::GetElementOrCharAt(isolate(), object, index), Object);
+ Object::GetElement(isolate(), object, index, language_mode()), Object);
return result;
}
bool use_ic = MigrateDeprecated(object) ? false : FLAG_use_ic;
- if (FLAG_harmony_scoping && object->IsGlobalObject() && name->IsString()) {
+ if (object->IsJSGlobalObject() && name->IsString()) {
// Look up in script context table.
Handle<String> str_name = Handle<String>::cast(name);
- Handle<GlobalObject> global = Handle<GlobalObject>::cast(object);
+ Handle<JSGlobalObject> global = Handle<JSGlobalObject>::cast(object);
Handle<ScriptContextTable> script_contexts(
global->native_context()->script_context_table());
ScriptContextTable::LookupResult lookup_result;
if (ScriptContextTable::Lookup(script_contexts, str_name, &lookup_result)) {
+ Handle<Object> result =
+ FixedArray::get(ScriptContextTable::GetContext(
+ script_contexts, lookup_result.context_index),
+ lookup_result.slot_index);
+ if (*result == *isolate()->factory()->the_hole_value()) {
+ // Do not install stubs and stay pre-monomorphic for
+ // uninitialized accesses.
+ return ReferenceError(name);
+ }
+
if (use_ic && LoadScriptContextFieldStub::Accepted(&lookup_result)) {
LoadScriptContextFieldStub stub(isolate(), &lookup_result);
PatchCache(name, stub.GetCode());
}
- return FixedArray::get(ScriptContextTable::GetContext(
- script_contexts, lookup_result.context_index),
- lookup_result.slot_index);
+ return result;
}
}
@@ -728,22 +706,23 @@
LookupIterator it(object, name);
LookupForRead(&it);
- if (it.IsFound() || !IsUndeclaredGlobal(object)) {
+ if (it.IsFound() || !ShouldThrowReferenceError(object)) {
// Update inline cache and stub cache.
if (use_ic) UpdateCaches(&it);
// Get the property.
Handle<Object> result;
- ASSIGN_RETURN_ON_EXCEPTION(isolate(), result, Object::GetProperty(&it),
- Object);
+
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate(), result, Object::GetProperty(&it, language_mode()), Object);
if (it.IsFound()) {
return result;
- } else if (!IsUndeclaredGlobal(object)) {
+ } else if (!ShouldThrowReferenceError(object)) {
LOG(isolate(), SuspectReadEvent(*name, *object));
return result;
}
}
- return ReferenceError("not_defined", name);
+ return ReferenceError(name);
}
@@ -764,76 +743,61 @@
bool IC::UpdatePolymorphicIC(Handle<Name> name, Handle<Code> code) {
if (!code->is_handler()) return false;
if (target()->is_keyed_stub() && state() != PROTOTYPE_FAILURE) return false;
- Handle<HeapType> type = receiver_type();
- TypeHandleList types;
+ Handle<Map> map = receiver_map();
+ MapHandleList maps;
CodeHandleList handlers;
- TargetTypes(&types);
- int number_of_types = types.length();
- int deprecated_types = 0;
+ TargetMaps(&maps);
+ int number_of_maps = maps.length();
+ int deprecated_maps = 0;
int handler_to_overwrite = -1;
- for (int i = 0; i < number_of_types; i++) {
- Handle<HeapType> current_type = types.at(i);
- if (current_type->IsClass() &&
- current_type->AsClass()->Map()->is_deprecated()) {
+ for (int i = 0; i < number_of_maps; i++) {
+ Handle<Map> current_map = maps.at(i);
+ if (current_map->is_deprecated()) {
// Filter out deprecated maps to ensure their instances get migrated.
- ++deprecated_types;
- } else if (type->NowIs(current_type)) {
+ ++deprecated_maps;
+ } else if (map.is_identical_to(current_map)) {
// If the receiver type is already in the polymorphic IC, this indicates
// there was a prototoype chain failure. In that case, just overwrite the
// handler.
handler_to_overwrite = i;
- } else if (handler_to_overwrite == -1 && current_type->IsClass() &&
- type->IsClass() &&
- IsTransitionOfMonomorphicTarget(*current_type->AsClass()->Map(),
- *type->AsClass()->Map())) {
+ } else if (handler_to_overwrite == -1 &&
+ IsTransitionOfMonomorphicTarget(*current_map, *map)) {
handler_to_overwrite = i;
}
}
- int number_of_valid_types =
- number_of_types - deprecated_types - (handler_to_overwrite != -1);
+ int number_of_valid_maps =
+ number_of_maps - deprecated_maps - (handler_to_overwrite != -1);
- if (number_of_valid_types >= 4) return false;
- if (number_of_types == 0 && state() != MONOMORPHIC &&
- state() != POLYMORPHIC) {
+ if (number_of_valid_maps >= 4) return false;
+ if (number_of_maps == 0 && state() != MONOMORPHIC && state() != POLYMORPHIC) {
return false;
}
if (UseVector()) {
- if (!nexus()->FindHandlers(&handlers, types.length())) return false;
+ if (!nexus()->FindHandlers(&handlers, maps.length())) return false;
} else {
- if (!target()->FindHandlers(&handlers, types.length())) return false;
+ if (!target()->FindHandlers(&handlers, maps.length())) return false;
}
- number_of_valid_types++;
- if (number_of_valid_types > 1 && target()->is_keyed_stub()) return false;
+ number_of_valid_maps++;
+ if (number_of_valid_maps > 1 && target()->is_keyed_stub()) return false;
Handle<Code> ic;
- if (number_of_valid_types == 1) {
- if (UseVector()) {
- ConfigureVectorState(name, receiver_type(), code);
- } else {
- ic = PropertyICCompiler::ComputeMonomorphic(kind(), name, type, code,
- extra_ic_state());
- }
+ if (number_of_valid_maps == 1) {
+ ConfigureVectorState(name, receiver_map(), code);
} else {
if (handler_to_overwrite >= 0) {
handlers.Set(handler_to_overwrite, code);
- if (!type->NowIs(types.at(handler_to_overwrite))) {
- types.Set(handler_to_overwrite, type);
+ if (!map.is_identical_to(maps.at(handler_to_overwrite))) {
+ maps.Set(handler_to_overwrite, map);
}
} else {
- types.Add(type);
+ maps.Add(map);
handlers.Add(code);
}
- if (UseVector()) {
- ConfigureVectorState(name, &types, &handlers);
- } else {
- ic = PropertyICCompiler::ComputePolymorphic(kind(), &types, &handlers,
- number_of_valid_types, name,
- extra_ic_state());
- }
+ ConfigureVectorState(name, &maps, &handlers);
}
if (!UseVector()) set_target(*ic);
@@ -841,66 +805,19 @@
}
-Handle<HeapType> IC::CurrentTypeOf(Handle<Object> object, Isolate* isolate) {
- return object->IsJSGlobalObject()
- ? HeapType::Constant(Handle<JSGlobalObject>::cast(object), isolate)
- : HeapType::NowOf(object, isolate);
-}
-
-
-Handle<Map> IC::TypeToMap(HeapType* type, Isolate* isolate) {
- if (type->Is(HeapType::Number()))
- return isolate->factory()->heap_number_map();
- if (type->Is(HeapType::Boolean())) return isolate->factory()->boolean_map();
- if (type->IsConstant()) {
- return handle(
- Handle<JSGlobalObject>::cast(type->AsConstant()->Value())->map());
- }
- DCHECK(type->IsClass());
- return type->AsClass()->Map();
-}
-
-
-template <class T>
-typename T::TypeHandle IC::MapToType(Handle<Map> map,
- typename T::Region* region) {
- if (map->instance_type() == HEAP_NUMBER_TYPE) {
- return T::Number(region);
- } else if (map->instance_type() == ODDBALL_TYPE) {
- // The only oddballs that can be recorded in ICs are booleans.
- return T::Boolean(region);
- } else {
- return T::Class(map, region);
- }
-}
-
-
-template Type* IC::MapToType<Type>(Handle<Map> map, Zone* zone);
-
-
-template Handle<HeapType> IC::MapToType<HeapType>(Handle<Map> map,
- Isolate* region);
-
-
void IC::UpdateMonomorphicIC(Handle<Code> handler, Handle<Name> name) {
DCHECK(handler->is_handler());
- if (UseVector()) {
- ConfigureVectorState(name, receiver_type(), handler);
- } else {
- Handle<Code> ic = PropertyICCompiler::ComputeMonomorphic(
- kind(), name, receiver_type(), handler, extra_ic_state());
- set_target(*ic);
- }
+ ConfigureVectorState(name, receiver_map(), handler);
}
void IC::CopyICToMegamorphicCache(Handle<Name> name) {
- TypeHandleList types;
+ MapHandleList maps;
CodeHandleList handlers;
- TargetTypes(&types);
- if (!target()->FindHandlers(&handlers, types.length())) return;
- for (int i = 0; i < types.length(); i++) {
- UpdateMegamorphicCache(*types.at(i), *name, *handlers.at(i));
+ TargetMaps(&maps);
+ if (!target()->FindHandlers(&handlers, maps.length())) return;
+ for (int i = 0; i < maps.length(); i++) {
+ UpdateMegamorphicCache(*maps.at(i), *name, *handlers.at(i));
}
}
@@ -936,26 +853,24 @@
CopyICToMegamorphicCache(name);
}
if (UseVector()) {
- ConfigureVectorState(kind() == Code::KEYED_LOAD_IC ? GENERIC
- : MEGAMORPHIC);
+ ConfigureVectorState(MEGAMORPHIC);
} else {
set_target(*megamorphic_stub());
}
// Fall through.
case MEGAMORPHIC:
- UpdateMegamorphicCache(*receiver_type(), *name, *code);
+ UpdateMegamorphicCache(*receiver_map(), *name, *code);
// Indicate that we've handled this case.
- target_set_ = true;
+ if (UseVector()) {
+ vector_set_ = true;
+ } else {
+ target_set_ = true;
+ }
break;
case DEBUG_STUB:
break;
- case DEFAULT:
- UNREACHABLE();
- break;
case GENERIC:
- // The generic keyed store stub re-uses store handlers, which can miss.
- // That's ok, no reason to do anything.
- DCHECK(target()->kind() == Code::KEYED_STORE_IC);
+ UNREACHABLE();
break;
}
}
@@ -963,70 +878,91 @@
Handle<Code> LoadIC::initialize_stub(Isolate* isolate,
ExtraICState extra_state) {
- if (FLAG_vector_ics) {
- return LoadICTrampolineStub(isolate, LoadICState(extra_state)).GetCode();
- }
-
- return PropertyICCompiler::ComputeLoad(isolate, UNINITIALIZED, extra_state);
+ return LoadICTrampolineStub(isolate, LoadICState(extra_state)).GetCode();
}
Handle<Code> LoadIC::initialize_stub_in_optimized_code(
- Isolate* isolate, ExtraICState extra_state) {
- if (FLAG_vector_ics) {
- return VectorLoadStub(isolate, LoadICState(extra_state)).GetCode();
- }
- return initialize_stub(isolate, extra_state);
+ Isolate* isolate, ExtraICState extra_state, State initialization_state) {
+ return LoadICStub(isolate, LoadICState(extra_state)).GetCode();
}
-Handle<Code> KeyedLoadIC::initialize_stub(Isolate* isolate) {
- if (FLAG_vector_ics) {
- return KeyedLoadICTrampolineStub(isolate).GetCode();
- }
-
- return isolate->builtins()->KeyedLoadIC_Initialize();
+Handle<Code> KeyedLoadIC::initialize_stub(Isolate* isolate,
+ ExtraICState extra_state) {
+ return KeyedLoadICTrampolineStub(isolate, LoadICState(extra_state)).GetCode();
}
-Handle<Code> KeyedLoadIC::initialize_stub_in_optimized_code(Isolate* isolate) {
- if (FLAG_vector_ics) {
- return VectorKeyedLoadStub(isolate).GetCode();
+Handle<Code> KeyedLoadIC::initialize_stub_in_optimized_code(
+ Isolate* isolate, State initialization_state, ExtraICState extra_state) {
+ if (initialization_state != MEGAMORPHIC) {
+ return KeyedLoadICStub(isolate, LoadICState(extra_state)).GetCode();
}
- return initialize_stub(isolate);
+ return is_strong(LoadICState::GetLanguageMode(extra_state))
+ ? isolate->builtins()->KeyedLoadIC_Megamorphic_Strong()
+ : isolate->builtins()->KeyedLoadIC_Megamorphic();
+}
+
+
+static Handle<Code> KeyedStoreICInitializeStubHelper(
+ Isolate* isolate, LanguageMode language_mode,
+ InlineCacheState initialization_state) {
+ switch (initialization_state) {
+ case UNINITIALIZED:
+ return is_strict(language_mode)
+ ? isolate->builtins()->KeyedStoreIC_Initialize_Strict()
+ : isolate->builtins()->KeyedStoreIC_Initialize();
+ case PREMONOMORPHIC:
+ return is_strict(language_mode)
+ ? isolate->builtins()->KeyedStoreIC_PreMonomorphic_Strict()
+ : isolate->builtins()->KeyedStoreIC_PreMonomorphic();
+ case MEGAMORPHIC:
+ return is_strict(language_mode)
+ ? isolate->builtins()->KeyedStoreIC_Megamorphic_Strict()
+ : isolate->builtins()->KeyedStoreIC_Megamorphic();
+ default:
+ UNREACHABLE();
+ }
+ return Handle<Code>();
+}
+
+
+Handle<Code> KeyedStoreIC::initialize_stub(Isolate* isolate,
+ LanguageMode language_mode,
+ State initialization_state) {
+ if (initialization_state != MEGAMORPHIC) {
+ VectorKeyedStoreICTrampolineStub stub(isolate, StoreICState(language_mode));
+ return stub.GetCode();
+ }
+
+ return KeyedStoreICInitializeStubHelper(isolate, language_mode,
+ initialization_state);
+}
+
+
+Handle<Code> KeyedStoreIC::initialize_stub_in_optimized_code(
+ Isolate* isolate, LanguageMode language_mode, State initialization_state) {
+ if (initialization_state != MEGAMORPHIC) {
+ VectorKeyedStoreICStub stub(isolate, StoreICState(language_mode));
+ return stub.GetCode();
+ }
+
+ return KeyedStoreICInitializeStubHelper(isolate, language_mode,
+ initialization_state);
+}
+
+
+Handle<Code> KeyedStoreIC::ChooseMegamorphicStub(Isolate* isolate,
+ ExtraICState extra_state) {
+ LanguageMode mode = StoreICState::GetLanguageMode(extra_state);
+ return KeyedStoreICInitializeStubHelper(isolate, mode, MEGAMORPHIC);
}
Handle<Code> LoadIC::megamorphic_stub() {
- if (kind() == Code::LOAD_IC) {
- MegamorphicLoadStub stub(isolate(), LoadICState(extra_ic_state()));
- return stub.GetCode();
- } else {
- DCHECK_EQ(Code::KEYED_LOAD_IC, kind());
- return KeyedLoadIC::generic_stub(isolate());
- }
-}
-
-
-Handle<Code> LoadIC::pre_monomorphic_stub(Isolate* isolate,
- ExtraICState extra_state) {
- DCHECK(!FLAG_vector_ics);
- return PropertyICCompiler::ComputeLoad(isolate, PREMONOMORPHIC, extra_state);
-}
-
-
-Handle<Code> KeyedLoadIC::pre_monomorphic_stub(Isolate* isolate) {
- return isolate->builtins()->KeyedLoadIC_PreMonomorphic();
-}
-
-
-Handle<Code> LoadIC::pre_monomorphic_stub() const {
- if (kind() == Code::LOAD_IC) {
- return LoadIC::pre_monomorphic_stub(isolate(), extra_ic_state());
- } else {
- DCHECK_EQ(Code::KEYED_LOAD_IC, kind());
- return KeyedLoadIC::pre_monomorphic_stub(isolate());
- }
+ DCHECK_EQ(Code::KEYED_LOAD_IC, kind());
+ return KeyedLoadIC::ChooseMegamorphicStub(isolate(), extra_ic_state());
}
@@ -1036,15 +972,44 @@
}
+bool IsCompatibleReceiver(LookupIterator* lookup, Handle<Map> receiver_map) {
+ DCHECK(lookup->state() == LookupIterator::ACCESSOR);
+ Isolate* isolate = lookup->isolate();
+ Handle<Object> accessors = lookup->GetAccessors();
+ if (accessors->IsExecutableAccessorInfo()) {
+ Handle<ExecutableAccessorInfo> info =
+ Handle<ExecutableAccessorInfo>::cast(accessors);
+ if (info->getter() != NULL &&
+ !ExecutableAccessorInfo::IsCompatibleReceiverMap(isolate, info,
+ receiver_map)) {
+ return false;
+ }
+ } else if (accessors->IsAccessorPair()) {
+ Handle<Object> getter(Handle<AccessorPair>::cast(accessors)->getter(),
+ isolate);
+ Handle<JSObject> holder = lookup->GetHolder<JSObject>();
+ Handle<Object> receiver = lookup->GetReceiver();
+ if (getter->IsJSFunction() && holder->HasFastProperties()) {
+ Handle<JSFunction> function = Handle<JSFunction>::cast(getter);
+ if (receiver->IsJSObject() || function->shared()->IsBuiltin() ||
+ !is_sloppy(function->shared()->language_mode())) {
+ CallOptimization call_optimization(function);
+ if (call_optimization.is_simple_api_call() &&
+ !call_optimization.IsCompatibleReceiverMap(receiver_map, holder)) {
+ return false;
+ }
+ }
+ }
+ }
+ return true;
+}
+
+
void LoadIC::UpdateCaches(LookupIterator* lookup) {
if (state() == UNINITIALIZED) {
// This is the first time we execute this inline cache. Set the target to
// the pre monomorphic stub to delay setting the monomorphic state.
- if (UseVector()) {
- ConfigureVectorState(PREMONOMORPHIC);
- } else {
- set_target(*pre_monomorphic_stub());
- }
+ ConfigureVectorState(PREMONOMORPHIC);
TRACE_IC("LoadIC", lookup->name());
return;
}
@@ -1054,16 +1019,33 @@
lookup->state() == LookupIterator::ACCESS_CHECK) {
code = slow_stub();
} else if (!lookup->IsFound()) {
- if (kind() == Code::LOAD_IC) {
+ if (kind() == Code::LOAD_IC && !is_strong(language_mode())) {
code = NamedLoadHandlerCompiler::ComputeLoadNonexistent(lookup->name(),
- receiver_type());
+ receiver_map());
// TODO(jkummerow/verwaest): Introduce a builtin that handles this case.
if (code.is_null()) code = slow_stub();
} else {
code = slow_stub();
}
} else {
- code = ComputeHandler(lookup);
+ if (lookup->state() == LookupIterator::ACCESSOR) {
+ if (!IsCompatibleReceiver(lookup, receiver_map())) {
+ TRACE_GENERIC_IC(isolate(), "LoadIC", "incompatible receiver type");
+ code = slow_stub();
+ }
+ } else if (lookup->state() == LookupIterator::INTERCEPTOR) {
+ // Perform a lookup behind the interceptor. Copy the LookupIterator since
+ // the original iterator will be used to fetch the value.
+ LookupIterator it = *lookup;
+ it.Next();
+ LookupForRead(&it);
+ if (it.state() == LookupIterator::ACCESSOR &&
+ !IsCompatibleReceiver(&it, receiver_map())) {
+ TRACE_GENERIC_IC(isolate(), "LoadIC", "incompatible receiver type");
+ code = slow_stub();
+ }
+ }
+ if (code.is_null()) code = ComputeHandler(lookup);
}
PatchCache(lookup->name(), code);
@@ -1071,10 +1053,7 @@
}
-void IC::UpdateMegamorphicCache(HeapType* type, Name* name, Code* code) {
- // Megamorphic state isn't implemented for keyed loads currently.
- if (kind() == Code::KEYED_LOAD_IC) return;
- Map* map = *TypeToMap(type, isolate());
+void IC::UpdateMegamorphicCache(Map* map, Name* name, Code* code) {
isolate()->stub_cache()->Set(name, map, code);
}
@@ -1084,7 +1063,7 @@
lookup->GetReceiver().is_identical_to(lookup->GetHolder<JSObject>());
CacheHolderFlag flag;
Handle<Map> stub_holder_map = IC::GetHandlerCacheHolder(
- *receiver_type(), receiver_is_holder, isolate(), &flag);
+ receiver_map(), receiver_is_holder, isolate(), &flag);
Handle<Code> code = PropertyHandlerCompiler::Find(
lookup->name(), stub_holder_map, kind(), flag,
@@ -1148,7 +1127,7 @@
// Use specialized code for getting prototype of functions.
if (receiver->IsJSFunction() &&
Name::Equals(isolate()->factory()->prototype_string(), lookup->name()) &&
- Handle<JSFunction>::cast(receiver)->should_have_prototype() &&
+ receiver->IsConstructor() &&
!Handle<JSFunction>::cast(receiver)
->map()
->has_non_instance_prototype()) {
@@ -1157,14 +1136,13 @@
return function_prototype_stub.GetCode();
}
- Handle<HeapType> type = receiver_type();
+ Handle<Map> map = receiver_map();
Handle<JSObject> holder = lookup->GetHolder<JSObject>();
bool receiver_is_holder = receiver.is_identical_to(holder);
switch (lookup->state()) {
case LookupIterator::INTERCEPTOR: {
DCHECK(!holder->GetNamedInterceptor()->getter()->IsUndefined());
- NamedLoadHandlerCompiler compiler(isolate(), receiver_type(), holder,
- cache_holder);
+ NamedLoadHandlerCompiler compiler(isolate(), map, holder, cache_holder);
// Perform a lookup behind the interceptor. Copy the LookupIterator since
// the original iterator will be used to fetch the value.
LookupIterator it = *lookup;
@@ -1175,16 +1153,19 @@
case LookupIterator::ACCESSOR: {
// Use simple field loads for some well-known callback properties.
- if (receiver_is_holder) {
- DCHECK(receiver->IsJSObject());
- Handle<JSObject> js_receiver = Handle<JSObject>::cast(receiver);
- int object_offset;
- if (Accessors::IsJSObjectFieldAccessor<HeapType>(type, lookup->name(),
- &object_offset)) {
- FieldIndex index =
- FieldIndex::ForInObjectOffset(object_offset, js_receiver->map());
- return SimpleFieldLoad(index);
- }
+ // The method will only return true for absolute truths based on the
+ // receiver maps.
+ int object_offset;
+ if (Accessors::IsJSObjectFieldAccessor(map, lookup->name(),
+ &object_offset)) {
+ FieldIndex index = FieldIndex::ForInObjectOffset(object_offset, *map);
+ return SimpleFieldLoad(index);
+ }
+ if (Accessors::IsJSArrayBufferViewFieldAccessor(map, lookup->name(),
+ &object_offset)) {
+ FieldIndex index = FieldIndex::ForInObjectOffset(object_offset, *map);
+ ArrayBufferViewLoadFieldStub stub(isolate(), index);
+ return stub.GetCode();
}
Handle<Object> accessors = lookup->GetAccessors();
@@ -1192,13 +1173,14 @@
Handle<ExecutableAccessorInfo> info =
Handle<ExecutableAccessorInfo>::cast(accessors);
if (v8::ToCData<Address>(info->getter()) == 0) break;
- if (!ExecutableAccessorInfo::IsCompatibleReceiverType(isolate(), info,
- type)) {
+ if (!ExecutableAccessorInfo::IsCompatibleReceiverMap(isolate(), info,
+ map)) {
+ // This case should be already handled in LoadIC::UpdateCaches.
+ UNREACHABLE();
break;
}
if (!holder->HasFastProperties()) break;
- NamedLoadHandlerCompiler compiler(isolate(), receiver_type(), holder,
- cache_holder);
+ NamedLoadHandlerCompiler compiler(isolate(), map, holder, cache_holder);
return compiler.CompileLoadCallback(lookup->name(), info);
}
if (accessors->IsAccessorPair()) {
@@ -1206,41 +1188,47 @@
isolate());
if (!getter->IsJSFunction()) break;
if (!holder->HasFastProperties()) break;
+ // When debugging we need to go the slow path to flood the accessor.
+ if (GetSharedFunctionInfo()->HasDebugInfo()) break;
Handle<JSFunction> function = Handle<JSFunction>::cast(getter);
- if (!receiver->IsJSObject() && !function->IsBuiltin() &&
- function->shared()->strict_mode() == SLOPPY) {
+ if (!receiver->IsJSObject() && !function->shared()->IsBuiltin() &&
+ is_sloppy(function->shared()->language_mode())) {
// Calling sloppy non-builtins with a value as the receiver
// requires boxing.
break;
}
CallOptimization call_optimization(function);
- NamedLoadHandlerCompiler compiler(isolate(), receiver_type(), holder,
- cache_holder);
- if (call_optimization.is_simple_api_call() &&
- call_optimization.IsCompatibleReceiver(receiver, holder)) {
- return compiler.CompileLoadCallback(lookup->name(),
- call_optimization);
+ NamedLoadHandlerCompiler compiler(isolate(), map, holder, cache_holder);
+ if (call_optimization.is_simple_api_call()) {
+ if (call_optimization.IsCompatibleReceiver(receiver, holder)) {
+ return compiler.CompileLoadCallback(
+ lookup->name(), call_optimization, lookup->GetAccessorIndex());
+ } else {
+ // This case should be already handled in LoadIC::UpdateCaches.
+ UNREACHABLE();
+ }
}
- return compiler.CompileLoadViaGetter(lookup->name(), function);
+ int expected_arguments =
+ function->shared()->internal_formal_parameter_count();
+ return compiler.CompileLoadViaGetter(
+ lookup->name(), lookup->GetAccessorIndex(), expected_arguments);
}
- // TODO(dcarney): Handle correctly.
- DCHECK(accessors->IsDeclaredAccessorInfo());
break;
}
case LookupIterator::DATA: {
if (lookup->is_dictionary_holder()) {
if (kind() != Code::LOAD_IC) break;
- if (holder->IsGlobalObject()) {
- NamedLoadHandlerCompiler compiler(isolate(), receiver_type(), holder,
+ if (holder->IsJSGlobalObject()) {
+ NamedLoadHandlerCompiler compiler(isolate(), map, holder,
cache_holder);
Handle<PropertyCell> cell = lookup->GetPropertyCell();
Handle<Code> code = compiler.CompileLoadGlobal(
cell, lookup->name(), lookup->IsConfigurable());
// TODO(verwaest): Move caching of these NORMAL stubs outside as well.
CacheHolderFlag flag;
- Handle<Map> stub_holder_map = GetHandlerCacheHolder(
- *type, receiver_is_holder, isolate(), &flag);
+ Handle<Map> stub_holder_map =
+ GetHandlerCacheHolder(map, receiver_is_holder, isolate(), &flag);
Map::UpdateCodeCache(stub_holder_map, lookup->name(), code);
return code;
}
@@ -1249,32 +1237,34 @@
// property must be found in the object for the stub to be
// applicable.
if (!receiver_is_holder) break;
- return isolate()->builtins()->LoadIC_Normal();
+ return is_strong(language_mode())
+ ? isolate()->builtins()->LoadIC_Normal_Strong()
+ : isolate()->builtins()->LoadIC_Normal();
}
// -------------- Fields --------------
- if (lookup->property_details().type() == FIELD) {
+ if (lookup->property_details().type() == DATA) {
FieldIndex field = lookup->GetFieldIndex();
if (receiver_is_holder) {
return SimpleFieldLoad(field);
}
- NamedLoadHandlerCompiler compiler(isolate(), receiver_type(), holder,
- cache_holder);
+ NamedLoadHandlerCompiler compiler(isolate(), map, holder, cache_holder);
return compiler.CompileLoadField(lookup->name(), field);
}
// -------------- Constant properties --------------
- DCHECK(lookup->property_details().type() == CONSTANT);
+ DCHECK(lookup->property_details().type() == DATA_CONSTANT);
if (receiver_is_holder) {
LoadConstantStub stub(isolate(), lookup->GetConstantIndex());
return stub.GetCode();
}
- NamedLoadHandlerCompiler compiler(isolate(), receiver_type(), holder,
- cache_holder);
+ NamedLoadHandlerCompiler compiler(isolate(), map, holder, cache_holder);
return compiler.CompileLoadConstant(lookup->name(),
lookup->GetConstantIndex());
}
+ case LookupIterator::INTEGER_INDEXED_EXOTIC:
+ return slow_stub();
case LookupIterator::ACCESS_CHECK:
case LookupIterator::JSPROXY:
case LookupIterator::NOT_FOUND:
@@ -1296,7 +1286,7 @@
} else {
int int_value = FastD2I(value);
if (value == int_value && Smi::IsValid(int_value)) {
- key = Handle<Smi>(Smi::FromInt(int_value), isolate);
+ key = handle(Smi::FromInt(int_value), isolate);
}
}
} else if (key->IsUndefined()) {
@@ -1314,13 +1304,11 @@
if (target_receiver_maps.length() == 0) {
- if (FLAG_vector_ics) {
- Handle<Code> handler =
- PropertyICCompiler::ComputeKeyedLoadMonomorphicHandler(receiver_map);
- ConfigureVectorState(Handle<Name>::null(), receiver_type(), handler);
- return null_handle;
- }
- return PropertyICCompiler::ComputeKeyedLoadMonomorphic(receiver_map);
+ Handle<Code> handler =
+ PropertyICCompiler::ComputeKeyedLoadMonomorphicHandler(
+ receiver_map, extra_ic_state());
+ ConfigureVectorState(Handle<Name>::null(), receiver_map, handler);
+ return null_handle;
}
// The first time a receiver is seen that is a transitioned version of the
@@ -1334,13 +1322,11 @@
IsMoreGeneralElementsKindTransition(
target_receiver_maps.at(0)->elements_kind(),
Handle<JSObject>::cast(receiver)->GetElementsKind())) {
- if (FLAG_vector_ics) {
- Handle<Code> handler =
- PropertyICCompiler::ComputeKeyedLoadMonomorphicHandler(receiver_map);
- ConfigureVectorState(Handle<Name>::null(), receiver_type(), handler);
- return null_handle;
- }
- return PropertyICCompiler::ComputeKeyedLoadMonomorphic(receiver_map);
+ Handle<Code> handler =
+ PropertyICCompiler::ComputeKeyedLoadMonomorphicHandler(
+ receiver_map, extra_ic_state());
+ ConfigureVectorState(Handle<Name>::null(), receiver_map, handler);
+ return null_handle;
}
DCHECK(state() != GENERIC);
@@ -1351,37 +1337,22 @@
// If the miss wasn't due to an unseen map, a polymorphic stub
// won't help, use the generic stub.
TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "same map added twice");
- if (FLAG_vector_ics) {
- ConfigureVectorState(GENERIC);
- return null_handle;
- }
- return generic_stub();
+ return megamorphic_stub();
}
// If the maximum number of receiver maps has been exceeded, use the generic
// version of the IC.
if (target_receiver_maps.length() > kMaxKeyedPolymorphism) {
TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "max polymorph exceeded");
- if (FLAG_vector_ics) {
- ConfigureVectorState(GENERIC);
- return null_handle;
- }
- return generic_stub();
+ return megamorphic_stub();
}
- if (FLAG_vector_ics) {
- CodeHandleList handlers(target_receiver_maps.length());
- ElementHandlerCompiler compiler(isolate());
- compiler.CompileElementHandlers(&target_receiver_maps, &handlers);
- TypeHandleList types(target_receiver_maps.length());
- for (int i = 0; i < target_receiver_maps.length(); i++) {
- types.Add(HeapType::Class(target_receiver_maps.at(i), isolate()));
- }
- ConfigureVectorState(Handle<Name>::null(), &types, &handlers);
- return null_handle;
- }
-
- return PropertyICCompiler::ComputeKeyedLoadPolymorphic(&target_receiver_maps);
+ CodeHandleList handlers(target_receiver_maps.length());
+ ElementHandlerCompiler compiler(isolate());
+ compiler.CompileElementHandlers(&target_receiver_maps, &handlers,
+ language_mode());
+ ConfigureVectorState(Handle<Name>::null(), &target_receiver_maps, &handlers);
+ return null_handle;
}
@@ -1390,13 +1361,14 @@
if (MigrateDeprecated(object)) {
Handle<Object> result;
ASSIGN_RETURN_ON_EXCEPTION(
- isolate(), result, Runtime::GetObjectProperty(isolate(), object, key),
+ isolate(), result,
+ Runtime::GetObjectProperty(isolate(), object, key, language_mode()),
Object);
return result;
}
Handle<Object> load_handle;
- Handle<Code> stub = generic_stub();
+ Handle<Code> stub = megamorphic_stub();
// Check for non-string values that can be converted into an
// internalized string directly or is representable as a smi.
@@ -1409,29 +1381,28 @@
} else if (FLAG_use_ic && !object->IsAccessCheckNeeded()) {
if (object->IsJSObject() || (object->IsString() && key->IsNumber())) {
Handle<HeapObject> receiver = Handle<HeapObject>::cast(object);
- if (object->IsString() || !Object::ToSmi(isolate(), key).is_null()) {
- stub = LoadElementStub(receiver);
- }
+ if (object->IsString() || key->IsSmi()) stub = LoadElementStub(receiver);
}
}
- if (!is_target_set()) {
- if (!FLAG_vector_ics) {
- Code* generic = *generic_stub();
- if (*stub == generic) {
- TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "set generic");
- }
-
- set_target(*stub);
+ DCHECK(UseVector());
+ if (!is_vector_set() || stub.is_null()) {
+ Code* generic = *megamorphic_stub();
+ if (!stub.is_null() && *stub == generic) {
+ ConfigureVectorState(MEGAMORPHIC);
+ TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "set generic");
}
+
TRACE_IC("LoadIC", key);
}
if (!load_handle.is_null()) return load_handle;
+
Handle<Object> result;
- ASSIGN_RETURN_ON_EXCEPTION(isolate(), result,
- Runtime::GetObjectProperty(isolate(), object, key),
- Object);
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate(), result,
+ Runtime::GetObjectProperty(isolate(), object, key, language_mode()),
+ Object);
return result;
}
@@ -1466,6 +1437,8 @@
break;
case LookupIterator::ACCESSOR:
return !it->IsReadOnly();
+ case LookupIterator::INTEGER_INDEXED_EXOTIC:
+ return false;
case LookupIterator::DATA: {
if (it->IsReadOnly()) return false;
Handle<JSObject> holder = it->GetHolder<JSObject>();
@@ -1473,7 +1446,7 @@
it->PrepareForDataProperty(value);
// The previous receiver map might just have been deprecated,
// so reload it.
- update_receiver_type(receiver);
+ update_receiver_map(receiver);
return true;
}
@@ -1484,6 +1457,8 @@
PrototypeIterator::GetCurrent(iter));
}
+ if (it->HolderIsReceiverOrHiddenPrototype()) return false;
+
it->PrepareTransitionToDataProperty(value, NONE, store_mode);
return it->IsCacheableTransition();
}
@@ -1498,10 +1473,31 @@
MaybeHandle<Object> StoreIC::Store(Handle<Object> object, Handle<Name> name,
Handle<Object> value,
JSReceiver::StoreFromKeyed store_mode) {
- if (FLAG_harmony_scoping && object->IsGlobalObject() && name->IsString()) {
+ // Check if the name is trivially convertible to an index and set the element.
+ uint32_t index;
+ if (kind() == Code::KEYED_STORE_IC && name->AsArrayIndex(&index)) {
+ // Rewrite to the generic keyed store stub.
+ if (FLAG_use_ic) {
+ if (UseVector()) {
+ ConfigureVectorState(MEGAMORPHIC);
+ } else if (!AddressIsDeoptimizedCode()) {
+ set_target(*megamorphic_stub());
+ }
+ TRACE_IC("StoreIC", name);
+ TRACE_GENERIC_IC(isolate(), "StoreIC", "name as array index");
+ }
+ Handle<Object> result;
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate(), result,
+ Object::SetElement(isolate(), object, index, value, language_mode()),
+ Object);
+ return result;
+ }
+
+ if (object->IsJSGlobalObject() && name->IsString()) {
// Look up in script context table.
Handle<String> str_name = Handle<String>::cast(name);
- Handle<GlobalObject> global = Handle<GlobalObject>::cast(object);
+ Handle<JSGlobalObject> global = Handle<JSGlobalObject>::cast(object);
Handle<ScriptContextTable> script_contexts(
global->native_context()->script_context_table());
@@ -1510,7 +1506,16 @@
Handle<Context> script_context = ScriptContextTable::GetContext(
script_contexts, lookup_result.context_index);
if (lookup_result.mode == CONST) {
- return TypeError("harmony_const_assign", object, name);
+ return TypeError(MessageTemplate::kConstAssign, object, name);
+ }
+
+ Handle<Object> previous_value =
+ FixedArray::get(script_context, lookup_result.slot_index);
+
+ if (*previous_value == *isolate()->factory()->the_hole_value()) {
+ // Do not install stubs and stay pre-monomorphic for
+ // uninitialized accesses.
+ return ReferenceError(name);
}
if (FLAG_use_ic &&
@@ -1530,30 +1535,14 @@
Handle<Object> result;
ASSIGN_RETURN_ON_EXCEPTION(
isolate(), result,
- Object::SetProperty(object, name, value, strict_mode()), Object);
+ Object::SetProperty(object, name, value, language_mode()), Object);
return result;
}
// If the object is undefined or null it's illegal to try to set any
// properties on it; throw a TypeError in that case.
if (object->IsUndefined() || object->IsNull()) {
- return TypeError("non_object_property_store", object, name);
- }
-
- // Check if the given name is an array index.
- uint32_t index;
- if (name->AsArrayIndex(&index)) {
- // Ignore other stores where the receiver is not a JSObject.
- // TODO(1475): Must check prototype chains of object wrappers.
- if (!object->IsJSObject()) return value;
- Handle<JSObject> receiver = Handle<JSObject>::cast(object);
-
- Handle<Object> result;
- ASSIGN_RETURN_ON_EXCEPTION(
- isolate(), result,
- JSObject::SetElement(receiver, index, value, NONE, strict_mode()),
- Object);
- return value;
+ return TypeError(MessageTemplate::kNonObjectPropertyStore, object, name);
}
// Observed objects are always modified through the runtime.
@@ -1562,7 +1551,7 @@
Handle<Object> result;
ASSIGN_RETURN_ON_EXCEPTION(
isolate(), result,
- Object::SetProperty(object, name, value, strict_mode(), store_mode),
+ Object::SetProperty(object, name, value, language_mode(), store_mode),
Object);
return result;
}
@@ -1570,39 +1559,70 @@
LookupIterator it(object, name);
if (FLAG_use_ic) UpdateCaches(&it, value, store_mode);
- // Set the property.
- Handle<Object> result;
- ASSIGN_RETURN_ON_EXCEPTION(
- isolate(), result,
- Object::SetProperty(&it, value, strict_mode(), store_mode), Object);
- return result;
+ MAYBE_RETURN_NULL(
+ Object::SetProperty(&it, value, language_mode(), store_mode));
+ return value;
}
Handle<Code> CallIC::initialize_stub(Isolate* isolate, int argc,
- CallICState::CallType call_type) {
- CallICStub stub(isolate, CallICState(argc, call_type));
+ ConvertReceiverMode mode) {
+ CallICTrampolineStub stub(isolate, CallICState(argc, mode));
Handle<Code> code = stub.GetCode();
return code;
}
-Handle<Code> StoreIC::initialize_stub(Isolate* isolate,
- StrictMode strict_mode) {
- ExtraICState extra_state = ComputeExtraICState(strict_mode);
- Handle<Code> ic =
- PropertyICCompiler::ComputeStore(isolate, UNINITIALIZED, extra_state);
+Handle<Code> CallIC::initialize_stub_in_optimized_code(
+ Isolate* isolate, int argc, ConvertReceiverMode mode) {
+ CallICStub stub(isolate, CallICState(argc, mode));
+ Handle<Code> code = stub.GetCode();
+ return code;
+}
+
+
+static Handle<Code> StoreICInitializeStubHelper(
+ Isolate* isolate, ExtraICState extra_state,
+ InlineCacheState initialization_state) {
+ Handle<Code> ic = PropertyICCompiler::ComputeStore(
+ isolate, initialization_state, extra_state);
return ic;
}
+Handle<Code> StoreIC::initialize_stub(Isolate* isolate,
+ LanguageMode language_mode,
+ State initialization_state) {
+ DCHECK(initialization_state == UNINITIALIZED ||
+ initialization_state == PREMONOMORPHIC ||
+ initialization_state == MEGAMORPHIC);
+ VectorStoreICTrampolineStub stub(isolate, StoreICState(language_mode));
+ return stub.GetCode();
+}
+
+
+Handle<Code> StoreIC::initialize_stub_in_optimized_code(
+ Isolate* isolate, LanguageMode language_mode, State initialization_state) {
+ DCHECK(initialization_state == UNINITIALIZED ||
+ initialization_state == PREMONOMORPHIC ||
+ initialization_state == MEGAMORPHIC);
+ if (initialization_state != MEGAMORPHIC) {
+ VectorStoreICStub stub(isolate, StoreICState(language_mode));
+ return stub.GetCode();
+ }
+
+ return StoreICInitializeStubHelper(
+ isolate, ComputeExtraICState(language_mode), initialization_state);
+}
+
+
Handle<Code> StoreIC::megamorphic_stub() {
if (kind() == Code::STORE_IC) {
return PropertyICCompiler::ComputeStore(isolate(), MEGAMORPHIC,
extra_ic_state());
} else {
DCHECK(kind() == Code::KEYED_STORE_IC);
- if (strict_mode() == STRICT) {
+ if (is_strict(language_mode())) {
return isolate()->builtins()->KeyedStoreIC_Megamorphic_Strict();
} else {
return isolate()->builtins()->KeyedStoreIC_Megamorphic();
@@ -1611,21 +1631,6 @@
}
-Handle<Code> StoreIC::generic_stub() const {
- if (kind() == Code::STORE_IC) {
- return PropertyICCompiler::ComputeStore(isolate(), GENERIC,
- extra_ic_state());
- } else {
- DCHECK(kind() == Code::KEYED_STORE_IC);
- if (strict_mode() == STRICT) {
- return isolate()->builtins()->KeyedStoreIC_Generic_Strict();
- } else {
- return isolate()->builtins()->KeyedStoreIC_Generic();
- }
- }
-}
-
-
Handle<Code> StoreIC::slow_stub() const {
if (kind() == Code::STORE_IC) {
return isolate()->builtins()->StoreIC_Slow();
@@ -1637,8 +1642,8 @@
Handle<Code> StoreIC::pre_monomorphic_stub(Isolate* isolate,
- StrictMode strict_mode) {
- ExtraICState state = ComputeExtraICState(strict_mode);
+ LanguageMode language_mode) {
+ ExtraICState state = ComputeExtraICState(language_mode);
return PropertyICCompiler::ComputeStore(isolate, PREMONOMORPHIC, state);
}
@@ -1648,7 +1653,7 @@
if (state() == UNINITIALIZED) {
// This is the first time we execute this inline cache. Set the target to
// the pre monomorphic stub to delay setting the monomorphic state.
- set_target(*pre_monomorphic_stub());
+ ConfigureVectorState(PREMONOMORPHIC);
TRACE_IC("StoreIC", lookup->name());
return;
}
@@ -1664,6 +1669,22 @@
}
+static Handle<Code> PropertyCellStoreHandler(
+ Isolate* isolate, Handle<JSObject> receiver, Handle<JSGlobalObject> holder,
+ Handle<Name> name, Handle<PropertyCell> cell, PropertyCellType type) {
+ auto constant_type = Nothing<PropertyCellConstantType>();
+ if (type == PropertyCellType::kConstantType) {
+ constant_type = Just(cell->GetConstantType());
+ }
+ StoreGlobalStub stub(isolate, type, constant_type,
+ receiver->IsJSGlobalProxy());
+ auto code = stub.GetCodeCopyFromTemplate(holder, cell);
+ // TODO(verwaest): Move caching of these NORMAL stubs outside as well.
+ HeapObject::UpdateMapCodeCache(receiver, name, code);
+ return code;
+}
+
+
Handle<Code> StoreIC::CompileHandler(LookupIterator* lookup,
Handle<Object> value,
CacheHolderFlag cache_holder) {
@@ -1672,10 +1693,22 @@
// This is currently guaranteed by checks in StoreIC::Store.
Handle<JSObject> receiver = Handle<JSObject>::cast(lookup->GetReceiver());
Handle<JSObject> holder = lookup->GetHolder<JSObject>();
- DCHECK(!receiver->IsAccessCheckNeeded());
+ DCHECK(!receiver->IsAccessCheckNeeded() ||
+ isolate()->IsInternallyUsedPropertyName(lookup->name()));
switch (lookup->state()) {
case LookupIterator::TRANSITION: {
+ auto store_target = lookup->GetStoreTarget();
+ if (store_target->IsJSGlobalObject()) {
+ // TODO(dcarney): this currently just deopts. Use the transition cell.
+ auto cell = isolate()->factory()->NewPropertyCell();
+ cell->set_value(*value);
+ auto code = PropertyCellStoreHandler(
+ isolate(), store_target, Handle<JSGlobalObject>::cast(store_target),
+ lookup->name(), cell, PropertyCellType::kConstant);
+ cell->set_value(isolate()->heap()->the_hole_value());
+ return code;
+ }
Handle<Map> transition = lookup->transition_map();
// Currently not handled by CompileStoreTransition.
if (!holder->HasFastProperties()) {
@@ -1684,13 +1717,13 @@
}
DCHECK(lookup->IsCacheableTransition());
- NamedStoreHandlerCompiler compiler(isolate(), receiver_type(), holder);
+ NamedStoreHandlerCompiler compiler(isolate(), receiver_map(), holder);
return compiler.CompileStoreTransition(transition, lookup->name());
}
case LookupIterator::INTERCEPTOR: {
DCHECK(!holder->GetNamedInterceptor()->setter()->IsUndefined());
- NamedStoreHandlerCompiler compiler(isolate(), receiver_type(), holder);
+ NamedStoreHandlerCompiler compiler(isolate(), receiver_map(), holder);
return compiler.CompileStoreInterceptor(lookup->name());
}
@@ -1707,12 +1740,18 @@
TRACE_GENERIC_IC(isolate(), "StoreIC", "setter == 0");
break;
}
- if (!ExecutableAccessorInfo::IsCompatibleReceiverType(
- isolate(), info, receiver_type())) {
+ if (AccessorInfo::cast(*accessors)->is_special_data_property() &&
+ !lookup->HolderIsReceiverOrHiddenPrototype()) {
+ TRACE_GENERIC_IC(isolate(), "StoreIC",
+ "special data property in prototype chain");
+ break;
+ }
+ if (!ExecutableAccessorInfo::IsCompatibleReceiverMap(isolate(), info,
+ receiver_map())) {
TRACE_GENERIC_IC(isolate(), "StoreIC", "incompatible receiver type");
break;
}
- NamedStoreHandlerCompiler compiler(isolate(), receiver_type(), holder);
+ NamedStoreHandlerCompiler compiler(isolate(), receiver_map(), holder);
return compiler.CompileStoreCallback(receiver, lookup->name(), info);
} else if (accessors->IsAccessorPair()) {
Handle<Object> setter(Handle<AccessorPair>::cast(accessors)->setter(),
@@ -1723,32 +1762,33 @@
}
Handle<JSFunction> function = Handle<JSFunction>::cast(setter);
CallOptimization call_optimization(function);
- NamedStoreHandlerCompiler compiler(isolate(), receiver_type(), holder);
+ NamedStoreHandlerCompiler compiler(isolate(), receiver_map(), holder);
if (call_optimization.is_simple_api_call() &&
call_optimization.IsCompatibleReceiver(receiver, holder)) {
return compiler.CompileStoreCallback(receiver, lookup->name(),
- call_optimization);
+ call_optimization,
+ lookup->GetAccessorIndex());
}
+ int expected_arguments =
+ function->shared()->internal_formal_parameter_count();
return compiler.CompileStoreViaSetter(receiver, lookup->name(),
- Handle<JSFunction>::cast(setter));
+ lookup->GetAccessorIndex(),
+ expected_arguments);
}
- // TODO(dcarney): Handle correctly.
- DCHECK(accessors->IsDeclaredAccessorInfo());
- TRACE_GENERIC_IC(isolate(), "StoreIC", "declared accessor info");
break;
}
case LookupIterator::DATA: {
if (lookup->is_dictionary_holder()) {
- if (holder->IsGlobalObject()) {
- Handle<PropertyCell> cell = lookup->GetPropertyCell();
- Handle<HeapType> union_type = PropertyCell::UpdatedType(cell, value);
- StoreGlobalStub stub(isolate(), union_type->IsConstant(),
- receiver->IsJSGlobalProxy());
- Handle<Code> code = stub.GetCodeCopyFromTemplate(
- Handle<GlobalObject>::cast(holder), cell);
- // TODO(verwaest): Move caching of these NORMAL stubs outside as well.
- HeapObject::UpdateMapCodeCache(receiver, lookup->name(), code);
+ if (holder->IsJSGlobalObject()) {
+ DCHECK(holder.is_identical_to(receiver) ||
+ receiver->map()->prototype() == *holder);
+ auto cell = lookup->GetPropertyCell();
+ auto updated_type = PropertyCell::UpdatedType(
+ cell, value, lookup->property_details());
+ auto code = PropertyCellStoreHandler(
+ isolate(), receiver, Handle<JSGlobalObject>::cast(holder),
+ lookup->name(), cell, updated_type);
return code;
}
DCHECK(holder.is_identical_to(receiver));
@@ -1756,7 +1796,7 @@
}
// -------------- Fields --------------
- if (lookup->property_details().type() == FIELD) {
+ if (lookup->property_details().type() == DATA) {
bool use_stub = true;
if (lookup->representation().IsHeapObject()) {
// Only use a generic stub if no types need to be tracked.
@@ -1769,16 +1809,17 @@
lookup->representation());
return stub.GetCode();
}
- NamedStoreHandlerCompiler compiler(isolate(), receiver_type(), holder);
+ NamedStoreHandlerCompiler compiler(isolate(), receiver_map(), holder);
return compiler.CompileStoreField(lookup);
}
// -------------- Constant properties --------------
- DCHECK(lookup->property_details().type() == CONSTANT);
+ DCHECK(lookup->property_details().type() == DATA_CONSTANT);
TRACE_GENERIC_IC(isolate(), "StoreIC", "constant property");
break;
}
+ case LookupIterator::INTEGER_INDEXED_EXOTIC:
case LookupIterator::ACCESS_CHECK:
case LookupIterator::JSPROXY:
case LookupIterator::NOT_FOUND:
@@ -1788,33 +1829,36 @@
}
-Handle<Code> KeyedStoreIC::StoreElementStub(Handle<JSObject> receiver,
+Handle<Code> KeyedStoreIC::StoreElementStub(Handle<Map> receiver_map,
KeyedAccessStoreMode store_mode) {
- // Don't handle megamorphic property accesses for INTERCEPTORS or CALLBACKS
+ Handle<Code> null_handle;
+ // Don't handle megamorphic property accesses for INTERCEPTORS or
+ // ACCESSOR_CONSTANT
// via megamorphic stubs, since they don't have a map in their relocation info
// and so the stubs can't be harvested for the object needed for a map check.
if (target()->type() != Code::NORMAL) {
TRACE_GENERIC_IC(isolate(), "KeyedStoreIC", "non-NORMAL target type");
- return generic_stub();
+ return megamorphic_stub();
}
- Handle<Map> receiver_map(receiver->map(), isolate());
MapHandleList target_receiver_maps;
TargetMaps(&target_receiver_maps);
if (target_receiver_maps.length() == 0) {
Handle<Map> monomorphic_map =
ComputeTransitionedMap(receiver_map, store_mode);
store_mode = GetNonTransitioningStoreMode(store_mode);
- return PropertyICCompiler::ComputeKeyedStoreMonomorphic(
- monomorphic_map, strict_mode(), store_mode);
+ Handle<Code> handler =
+ PropertyICCompiler::ComputeKeyedStoreMonomorphicHandler(
+ monomorphic_map, language_mode(), store_mode);
+ ConfigureVectorState(Handle<Name>::null(), monomorphic_map, handler);
+ return null_handle;
}
// There are several special cases where an IC that is MONOMORPHIC can still
// transition to a different GetNonTransitioningStoreMode IC that handles a
// superset of the original IC. Handle those here if the receiver map hasn't
// changed or it has transitioned to a more general kind.
- KeyedAccessStoreMode old_store_mode =
- KeyedStoreIC::GetKeyedAccessStoreMode(target()->extra_ic_state());
+ KeyedAccessStoreMode old_store_mode = GetKeyedAccessStoreMode();
Handle<Map> previous_receiver_map = target_receiver_maps.at(0);
if (state() == MONOMORPHIC) {
Handle<Map> transitioned_receiver_map = receiver_map;
@@ -1830,9 +1874,13 @@
// if they at least come from the same origin for a transitioning store,
// stay MONOMORPHIC and use the map for the most generic ElementsKind.
store_mode = GetNonTransitioningStoreMode(store_mode);
- return PropertyICCompiler::ComputeKeyedStoreMonomorphic(
- transitioned_receiver_map, strict_mode(), store_mode);
- } else if (*previous_receiver_map == receiver->map() &&
+ Handle<Code> handler =
+ PropertyICCompiler::ComputeKeyedStoreMonomorphicHandler(
+ transitioned_receiver_map, language_mode(), store_mode);
+ ConfigureVectorState(Handle<Name>::null(), transitioned_receiver_map,
+ handler);
+ return null_handle;
+ } else if (receiver_map.is_identical_to(previous_receiver_map) &&
old_store_mode == STANDARD_STORE &&
(store_mode == STORE_AND_GROW_NO_TRANSITION ||
store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS ||
@@ -1840,8 +1888,11 @@
// A "normal" IC that handles stores can switch to a version that can
// grow at the end of the array, handle OOB accesses or copy COW arrays
// and still stay MONOMORPHIC.
- return PropertyICCompiler::ComputeKeyedStoreMonomorphic(
- receiver_map, strict_mode(), store_mode);
+ Handle<Code> handler =
+ PropertyICCompiler::ComputeKeyedStoreMonomorphicHandler(
+ receiver_map, language_mode(), store_mode);
+ ConfigureVectorState(Handle<Name>::null(), receiver_map, handler);
+ return null_handle;
}
}
@@ -1859,9 +1910,9 @@
if (!map_added) {
// If the miss wasn't due to an unseen map, a polymorphic stub
- // won't help, use the generic stub.
+ // won't help, use the megamorphic stub which can handle everything.
TRACE_GENERIC_IC(isolate(), "KeyedStoreIC", "same map added twice");
- return generic_stub();
+ return megamorphic_stub();
}
// If the maximum number of receiver maps has been exceeded, use the
@@ -1871,25 +1922,24 @@
}
// Make sure all polymorphic handlers have the same store mode, otherwise the
- // generic stub must be used.
+ // megamorphic stub must be used.
store_mode = GetNonTransitioningStoreMode(store_mode);
if (old_store_mode != STANDARD_STORE) {
if (store_mode == STANDARD_STORE) {
store_mode = old_store_mode;
} else if (store_mode != old_store_mode) {
TRACE_GENERIC_IC(isolate(), "KeyedStoreIC", "store mode mismatch");
- return generic_stub();
+ return megamorphic_stub();
}
}
// If the store mode isn't the standard mode, make sure that all polymorphic
// receivers are either external arrays, or all "normal" arrays. Otherwise,
- // use the generic stub.
+ // use the megamorphic stub.
if (store_mode != STANDARD_STORE) {
int external_arrays = 0;
for (int i = 0; i < target_receiver_maps.length(); ++i) {
- if (target_receiver_maps[i]->has_external_array_elements() ||
- target_receiver_maps[i]->has_fixed_typed_array_elements()) {
+ if (target_receiver_maps[i]->has_fixed_typed_array_elements()) {
external_arrays++;
}
}
@@ -1897,36 +1947,39 @@
external_arrays != target_receiver_maps.length()) {
TRACE_GENERIC_IC(isolate(), "KeyedStoreIC",
"unsupported combination of external and normal arrays");
- return generic_stub();
+ return megamorphic_stub();
}
}
- return PropertyICCompiler::ComputeKeyedStorePolymorphic(
- &target_receiver_maps, store_mode, strict_mode());
+ MapHandleList transitioned_maps(target_receiver_maps.length());
+ CodeHandleList handlers(target_receiver_maps.length());
+ PropertyICCompiler::ComputeKeyedStorePolymorphicHandlers(
+ &target_receiver_maps, &transitioned_maps, &handlers, store_mode,
+ language_mode());
+ ConfigureVectorState(&target_receiver_maps, &transitioned_maps, &handlers);
+ return null_handle;
}
Handle<Map> KeyedStoreIC::ComputeTransitionedMap(
Handle<Map> map, KeyedAccessStoreMode store_mode) {
switch (store_mode) {
- case STORE_TRANSITION_SMI_TO_OBJECT:
- case STORE_TRANSITION_DOUBLE_TO_OBJECT:
- case STORE_AND_GROW_TRANSITION_SMI_TO_OBJECT:
- case STORE_AND_GROW_TRANSITION_DOUBLE_TO_OBJECT:
- return Map::TransitionElementsTo(map, FAST_ELEMENTS);
- case STORE_TRANSITION_SMI_TO_DOUBLE:
- case STORE_AND_GROW_TRANSITION_SMI_TO_DOUBLE:
- return Map::TransitionElementsTo(map, FAST_DOUBLE_ELEMENTS);
- case STORE_TRANSITION_HOLEY_SMI_TO_OBJECT:
- case STORE_TRANSITION_HOLEY_DOUBLE_TO_OBJECT:
- case STORE_AND_GROW_TRANSITION_HOLEY_SMI_TO_OBJECT:
- case STORE_AND_GROW_TRANSITION_HOLEY_DOUBLE_TO_OBJECT:
- return Map::TransitionElementsTo(map, FAST_HOLEY_ELEMENTS);
- case STORE_TRANSITION_HOLEY_SMI_TO_DOUBLE:
- case STORE_AND_GROW_TRANSITION_HOLEY_SMI_TO_DOUBLE:
- return Map::TransitionElementsTo(map, FAST_HOLEY_DOUBLE_ELEMENTS);
+ case STORE_TRANSITION_TO_OBJECT:
+ case STORE_AND_GROW_TRANSITION_TO_OBJECT: {
+ ElementsKind kind = IsFastHoleyElementsKind(map->elements_kind())
+ ? FAST_HOLEY_ELEMENTS
+ : FAST_ELEMENTS;
+ return Map::TransitionElementsTo(map, kind);
+ }
+ case STORE_TRANSITION_TO_DOUBLE:
+ case STORE_AND_GROW_TRANSITION_TO_DOUBLE: {
+ ElementsKind kind = IsFastHoleyElementsKind(map->elements_kind())
+ ? FAST_HOLEY_DOUBLE_ELEMENTS
+ : FAST_DOUBLE_ELEMENTS;
+ return Map::TransitionElementsTo(map, kind);
+ }
case STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS:
- DCHECK(map->has_external_array_elements());
+ DCHECK(map->has_fixed_typed_array_elements());
// Fall through
case STORE_NO_TRANSITION_HANDLE_COW:
case STANDARD_STORE:
@@ -1938,49 +1991,36 @@
}
-bool IsOutOfBoundsAccess(Handle<JSObject> receiver, int index) {
+bool IsOutOfBoundsAccess(Handle<JSObject> receiver, uint32_t index) {
+ uint32_t length = 0;
if (receiver->IsJSArray()) {
- return JSArray::cast(*receiver)->length()->IsSmi() &&
- index >= Smi::cast(JSArray::cast(*receiver)->length())->value();
+ JSArray::cast(*receiver)->length()->ToArrayLength(&length);
+ } else {
+ length = static_cast<uint32_t>(receiver->elements()->length());
}
- return index >= receiver->elements()->length();
+ return index >= length;
}
-KeyedAccessStoreMode KeyedStoreIC::GetStoreMode(Handle<JSObject> receiver,
- Handle<Object> key,
- Handle<Object> value) {
- Handle<Smi> smi_key = Object::ToSmi(isolate(), key).ToHandleChecked();
- int index = smi_key->value();
+static KeyedAccessStoreMode GetStoreMode(Handle<JSObject> receiver,
+ uint32_t index, Handle<Object> value) {
bool oob_access = IsOutOfBoundsAccess(receiver, index);
// Don't consider this a growing store if the store would send the receiver to
// dictionary mode.
bool allow_growth = receiver->IsJSArray() && oob_access &&
- !receiver->WouldConvertToSlowElements(key);
+ !receiver->WouldConvertToSlowElements(index);
if (allow_growth) {
// Handle growing array in stub if necessary.
if (receiver->HasFastSmiElements()) {
if (value->IsHeapNumber()) {
- if (receiver->HasFastHoleyElements()) {
- return STORE_AND_GROW_TRANSITION_HOLEY_SMI_TO_DOUBLE;
- } else {
- return STORE_AND_GROW_TRANSITION_SMI_TO_DOUBLE;
- }
+ return STORE_AND_GROW_TRANSITION_TO_DOUBLE;
}
if (value->IsHeapObject()) {
- if (receiver->HasFastHoleyElements()) {
- return STORE_AND_GROW_TRANSITION_HOLEY_SMI_TO_OBJECT;
- } else {
- return STORE_AND_GROW_TRANSITION_SMI_TO_OBJECT;
- }
+ return STORE_AND_GROW_TRANSITION_TO_OBJECT;
}
} else if (receiver->HasFastDoubleElements()) {
if (!value->IsSmi() && !value->IsHeapNumber()) {
- if (receiver->HasFastHoleyElements()) {
- return STORE_AND_GROW_TRANSITION_HOLEY_DOUBLE_TO_OBJECT;
- } else {
- return STORE_AND_GROW_TRANSITION_DOUBLE_TO_OBJECT;
- }
+ return STORE_AND_GROW_TRANSITION_TO_OBJECT;
}
}
return STORE_AND_GROW_NO_TRANSITION;
@@ -1988,29 +2028,17 @@
// Handle only in-bounds elements accesses.
if (receiver->HasFastSmiElements()) {
if (value->IsHeapNumber()) {
- if (receiver->HasFastHoleyElements()) {
- return STORE_TRANSITION_HOLEY_SMI_TO_DOUBLE;
- } else {
- return STORE_TRANSITION_SMI_TO_DOUBLE;
- }
+ return STORE_TRANSITION_TO_DOUBLE;
} else if (value->IsHeapObject()) {
- if (receiver->HasFastHoleyElements()) {
- return STORE_TRANSITION_HOLEY_SMI_TO_OBJECT;
- } else {
- return STORE_TRANSITION_SMI_TO_OBJECT;
- }
+ return STORE_TRANSITION_TO_OBJECT;
}
} else if (receiver->HasFastDoubleElements()) {
if (!value->IsSmi() && !value->IsHeapNumber()) {
- if (receiver->HasFastHoleyElements()) {
- return STORE_TRANSITION_HOLEY_DOUBLE_TO_OBJECT;
- } else {
- return STORE_TRANSITION_DOUBLE_TO_OBJECT;
- }
+ return STORE_TRANSITION_TO_OBJECT;
}
}
if (!FLAG_trace_external_array_abuse &&
- receiver->map()->has_external_array_elements() && oob_access) {
+ receiver->map()->has_fixed_typed_array_elements() && oob_access) {
return STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS;
}
Heap* heap = receiver->GetHeap();
@@ -2032,7 +2060,7 @@
Handle<Object> result;
ASSIGN_RETURN_ON_EXCEPTION(
isolate(), result, Runtime::SetObjectProperty(isolate(), object, key,
- value, strict_mode()),
+ value, language_mode()),
Object);
return result;
}
@@ -2042,19 +2070,22 @@
key = TryConvertKey(key, isolate());
Handle<Object> store_handle;
- Handle<Code> stub = generic_stub();
+ Handle<Code> stub = megamorphic_stub();
- if (key->IsInternalizedString()) {
+ uint32_t index;
+ if ((key->IsInternalizedString() &&
+ !String::cast(*key)->AsArrayIndex(&index)) ||
+ key->IsSymbol()) {
ASSIGN_RETURN_ON_EXCEPTION(
isolate(), store_handle,
- StoreIC::Store(object, Handle<String>::cast(key), value,
+ StoreIC::Store(object, Handle<Name>::cast(key), value,
JSReceiver::MAY_BE_STORE_FROM_KEYED),
Object);
- if (!is_target_set()) {
+ if (!is_vector_set()) {
+ ConfigureVectorState(MEGAMORPHIC);
TRACE_GENERIC_IC(isolate(), "KeyedStoreIC",
"unhandled internalized string key");
TRACE_IC("StoreIC", key);
- set_target(*stub);
}
return store_handle;
}
@@ -2074,30 +2105,46 @@
}
}
- if (use_ic) {
- DCHECK(!object->IsAccessCheckNeeded());
+ Handle<Map> old_receiver_map;
+ bool sloppy_arguments_elements = false;
+ bool key_is_valid_index = false;
+ KeyedAccessStoreMode store_mode = STANDARD_STORE;
+ if (use_ic && object->IsJSObject()) {
+ Handle<JSObject> receiver = Handle<JSObject>::cast(object);
+ old_receiver_map = handle(receiver->map(), isolate());
+ sloppy_arguments_elements =
+ !is_sloppy(language_mode()) &&
+ receiver->elements()->map() ==
+ isolate()->heap()->sloppy_arguments_elements_map();
+ if (!sloppy_arguments_elements) {
+ key_is_valid_index = key->IsSmi() && Smi::cast(*key)->value() >= 0;
+ if (key_is_valid_index) {
+ uint32_t index = static_cast<uint32_t>(Smi::cast(*key)->value());
+ store_mode = GetStoreMode(receiver, index, value);
+ }
+ }
+ }
- if (object->IsJSObject()) {
- Handle<JSObject> receiver = Handle<JSObject>::cast(object);
- bool key_is_smi_like = !Object::ToSmi(isolate(), key).is_null();
- if (receiver->elements()->map() ==
- isolate()->heap()->sloppy_arguments_elements_map()) {
- if (strict_mode() == SLOPPY) {
- stub = sloppy_arguments_stub();
- } else {
- TRACE_GENERIC_IC(isolate(), "KeyedStoreIC", "arguments receiver");
- }
- } else if (key_is_smi_like &&
- !(target().is_identical_to(sloppy_arguments_stub()))) {
+ DCHECK(store_handle.is_null());
+ ASSIGN_RETURN_ON_EXCEPTION(isolate(), store_handle,
+ Runtime::SetObjectProperty(isolate(), object, key,
+ value, language_mode()),
+ Object);
+
+ if (use_ic) {
+ if (!old_receiver_map.is_null()) {
+ if (sloppy_arguments_elements) {
+ TRACE_GENERIC_IC(isolate(), "KeyedStoreIC", "arguments receiver");
+ } else if (key_is_valid_index) {
// We should go generic if receiver isn't a dictionary, but our
// prototype chain does have dictionary elements. This ensures that
// other non-dictionary receivers in the polymorphic case benefit
// from fast path keyed stores.
- if (!(receiver->map()->DictionaryElementsInPrototypeChainOnly())) {
- KeyedAccessStoreMode store_mode = GetStoreMode(receiver, key, value);
- stub = StoreElementStub(receiver, store_mode);
+ if (!old_receiver_map->DictionaryElementsInPrototypeChainOnly()) {
+ stub = StoreElementStub(old_receiver_map, store_mode);
} else {
- TRACE_GENERIC_IC(isolate(), "KeyedStoreIC", "dictionary prototype");
+ TRACE_GENERIC_IC(isolate(), "KeyedStoreIC",
+ "dictionary or proxy prototype");
}
} else {
TRACE_GENERIC_IC(isolate(), "KeyedStoreIC", "non-smi-like key");
@@ -2107,90 +2154,21 @@
}
}
- if (store_handle.is_null()) {
- ASSIGN_RETURN_ON_EXCEPTION(
- isolate(), store_handle,
- Runtime::SetObjectProperty(isolate(), object, key, value,
- strict_mode()),
- Object);
+ if (!is_vector_set() || stub.is_null()) {
+ Code* megamorphic = *megamorphic_stub();
+ if (!stub.is_null() && (*stub == megamorphic || *stub == *slow_stub())) {
+ ConfigureVectorState(MEGAMORPHIC);
+ TRACE_GENERIC_IC(isolate(), "KeyedStoreIC",
+ *stub == megamorphic ? "set generic" : "slow stub");
+ }
}
-
- DCHECK(!is_target_set());
- Code* generic = *generic_stub();
- if (*stub == generic) {
- TRACE_GENERIC_IC(isolate(), "KeyedStoreIC", "set generic");
- }
- if (*stub == *slow_stub()) {
- TRACE_GENERIC_IC(isolate(), "KeyedStoreIC", "slow stub");
- }
- DCHECK(!stub.is_null());
- set_target(*stub);
TRACE_IC("StoreIC", key);
return store_handle;
}
-// static
-void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm,
- StrictMode strict_mode) {
- PropertyICCompiler::GenerateRuntimeSetProperty(masm, strict_mode);
-}
-
-
-bool CallIC::DoCustomHandler(Handle<Object> receiver, Handle<Object> function,
- const CallICState& callic_state) {
- DCHECK(FLAG_use_ic && function->IsJSFunction());
-
- // Are we the array function?
- Handle<JSFunction> array_function =
- Handle<JSFunction>(isolate()->native_context()->array_function());
- if (array_function.is_identical_to(Handle<JSFunction>::cast(function))) {
- // Alter the slot.
- CallICNexus* nexus = casted_nexus<CallICNexus>();
- nexus->ConfigureMonomorphicArray();
-
- CallIC_ArrayStub stub(isolate(), callic_state);
- set_target(*stub.GetCode());
- Handle<String> name;
- if (array_function->shared()->name()->IsString()) {
- name = Handle<String>(String::cast(array_function->shared()->name()),
- isolate());
- }
- TRACE_IC("CallIC", name);
- OnTypeFeedbackChanged(isolate(), get_host(), nexus->vector(), state(),
- MONOMORPHIC);
- return true;
- }
- return false;
-}
-
-
-void CallIC::PatchMegamorphic(Handle<Object> function) {
- CallICState callic_state(target()->extra_ic_state());
-
- // We are going generic.
- CallICNexus* nexus = casted_nexus<CallICNexus>();
- nexus->ConfigureGeneric();
-
- CallICStub stub(isolate(), callic_state);
- Handle<Code> code = stub.GetCode();
- set_target(*code);
-
- Handle<Object> name = isolate()->factory()->empty_string();
- if (function->IsJSFunction()) {
- Handle<JSFunction> js_function = Handle<JSFunction>::cast(function);
- name = handle(js_function->shared()->name(), isolate());
- }
-
- TRACE_IC("CallIC", name);
- OnTypeFeedbackChanged(isolate(), get_host(), nexus->vector(), state(),
- GENERIC);
-}
-
-
-void CallIC::HandleMiss(Handle<Object> receiver, Handle<Object> function) {
- CallICState callic_state(target()->extra_ic_state());
+void CallIC::HandleMiss(Handle<Object> function) {
Handle<Object> name = isolate()->factory()->empty_string();
CallICNexus* nexus = casted_nexus<CallICNexus>();
Object* feedback = nexus->GetFeedback();
@@ -2198,25 +2176,28 @@
// Hand-coded MISS handling is easier if CallIC slots don't contain smis.
DCHECK(!feedback->IsSmi());
- if (feedback->IsJSFunction() || !function->IsJSFunction()) {
+ if (feedback->IsWeakCell() || !function->IsJSFunction() ||
+ feedback->IsAllocationSite()) {
// We are going generic.
- nexus->ConfigureGeneric();
+ nexus->ConfigureMegamorphic();
} else {
- // The feedback is either uninitialized or an allocation site.
- // It might be an allocation site because if we re-compile the full code
- // to add deoptimization support, we call with the default call-ic, and
- // merely need to patch the target to match the feedback.
- // TODO(mvstanton): the better approach is to dispense with patching
- // altogether, which is in progress.
- DCHECK(feedback == *TypeFeedbackVector::UninitializedSentinel(isolate()) ||
- feedback->IsAllocationSite());
+ DCHECK(feedback == *TypeFeedbackVector::UninitializedSentinel(isolate()));
+ Handle<JSFunction> js_function = Handle<JSFunction>::cast(function);
- // Do we want to install a custom handler?
- if (FLAG_use_ic && DoCustomHandler(receiver, function, callic_state)) {
- return;
+ Handle<JSFunction> array_function =
+ Handle<JSFunction>(isolate()->native_context()->array_function());
+ if (array_function.is_identical_to(js_function)) {
+ // Alter the slot.
+ nexus->ConfigureMonomorphicArray();
+ } else if (js_function->context()->native_context() !=
+ *isolate()->native_context()) {
+ // Don't collect cross-native context feedback for the CallIC.
+ // TODO(bmeurer): We should collect the SharedFunctionInfo as
+ // feedback in this case instead.
+ nexus->ConfigureMegamorphic();
+ } else {
+ nexus->ConfigureMonomorphic(js_function);
}
-
- nexus->ConfigureMonomorphic(Handle<JSFunction>::cast(function));
}
if (function->IsJSFunction()) {
@@ -2224,8 +2205,7 @@
name = handle(js_function->shared()->name(), isolate());
}
- IC::State new_state = nexus->StateFromFeedback();
- OnTypeFeedbackChanged(isolate(), get_host(), *vector(), state(), new_state);
+ OnTypeFeedbackChanged(isolate(), get_host());
TRACE_IC("CallIC", name);
}
@@ -2238,71 +2218,46 @@
//
// Used from ic-<arch>.cc.
-RUNTIME_FUNCTION(CallIC_Miss) {
+RUNTIME_FUNCTION(Runtime_CallIC_Miss) {
TimerEventScope<TimerEventIcMiss> timer(isolate);
HandleScope scope(isolate);
- DCHECK(args.length() == 4);
- Handle<Object> receiver = args.at<Object>(0);
- Handle<Object> function = args.at<Object>(1);
- Handle<TypeFeedbackVector> vector = args.at<TypeFeedbackVector>(2);
- Handle<Smi> slot = args.at<Smi>(3);
- FeedbackVectorICSlot vector_slot = vector->ToICSlot(slot->value());
+ DCHECK(args.length() == 3);
+ Handle<Object> function = args.at<Object>(0);
+ Handle<TypeFeedbackVector> vector = args.at<TypeFeedbackVector>(1);
+ Handle<Smi> slot = args.at<Smi>(2);
+ FeedbackVectorSlot vector_slot = vector->ToSlot(slot->value());
CallICNexus nexus(vector, vector_slot);
CallIC ic(isolate, &nexus);
- ic.HandleMiss(receiver, function);
- return *function;
-}
-
-
-RUNTIME_FUNCTION(CallIC_Customization_Miss) {
- TimerEventScope<TimerEventIcMiss> timer(isolate);
- HandleScope scope(isolate);
- DCHECK(args.length() == 4);
- Handle<Object> function = args.at<Object>(1);
- Handle<TypeFeedbackVector> vector = args.at<TypeFeedbackVector>(2);
- Handle<Smi> slot = args.at<Smi>(3);
- FeedbackVectorICSlot vector_slot = vector->ToICSlot(slot->value());
- CallICNexus nexus(vector, vector_slot);
- // A miss on a custom call ic always results in going megamorphic.
- CallIC ic(isolate, &nexus);
- ic.PatchMegamorphic(function);
+ ic.HandleMiss(function);
return *function;
}
// Used from ic-<arch>.cc.
-RUNTIME_FUNCTION(LoadIC_Miss) {
+RUNTIME_FUNCTION(Runtime_LoadIC_Miss) {
TimerEventScope<TimerEventIcMiss> timer(isolate);
HandleScope scope(isolate);
Handle<Object> receiver = args.at<Object>(0);
Handle<Name> key = args.at<Name>(1);
Handle<Object> result;
- if (FLAG_vector_ics) {
- DCHECK(args.length() == 4);
- Handle<Smi> slot = args.at<Smi>(2);
- Handle<TypeFeedbackVector> vector = args.at<TypeFeedbackVector>(3);
- FeedbackVectorICSlot vector_slot = vector->ToICSlot(slot->value());
- // A monomorphic or polymorphic KeyedLoadIC with a string key can call the
- // LoadIC miss handler if the handler misses. Since the vector Nexus is
- // set up outside the IC, handle that here.
- if (vector->GetKind(vector_slot) == Code::LOAD_IC) {
- LoadICNexus nexus(vector, vector_slot);
- LoadIC ic(IC::NO_EXTRA_FRAME, isolate, &nexus);
- ic.UpdateState(receiver, key);
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
- ic.Load(receiver, key));
- } else {
- DCHECK(vector->GetKind(vector_slot) == Code::KEYED_LOAD_IC);
- KeyedLoadICNexus nexus(vector, vector_slot);
- KeyedLoadIC ic(IC::NO_EXTRA_FRAME, isolate, &nexus);
- ic.UpdateState(receiver, key);
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
- ic.Load(receiver, key));
- }
+ DCHECK(args.length() == 4);
+ Handle<Smi> slot = args.at<Smi>(2);
+ Handle<TypeFeedbackVector> vector = args.at<TypeFeedbackVector>(3);
+ FeedbackVectorSlot vector_slot = vector->ToSlot(slot->value());
+ // A monomorphic or polymorphic KeyedLoadIC with a string key can call the
+ // LoadIC miss handler if the handler misses. Since the vector Nexus is
+ // set up outside the IC, handle that here.
+ if (vector->GetKind(vector_slot) == FeedbackVectorSlotKind::LOAD_IC) {
+ LoadICNexus nexus(vector, vector_slot);
+ LoadIC ic(IC::NO_EXTRA_FRAME, isolate, &nexus);
+ ic.UpdateState(receiver, key);
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, ic.Load(receiver, key));
} else {
- DCHECK(args.length() == 2);
- LoadIC ic(IC::NO_EXTRA_FRAME, isolate);
+ DCHECK_EQ(FeedbackVectorSlotKind::KEYED_LOAD_IC,
+ vector->GetKind(vector_slot));
+ KeyedLoadICNexus nexus(vector, vector_slot);
+ KeyedLoadIC ic(IC::NO_EXTRA_FRAME, isolate, &nexus);
ic.UpdateState(receiver, key);
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, ic.Load(receiver, key));
}
@@ -2311,164 +2266,221 @@
// Used from ic-<arch>.cc
-RUNTIME_FUNCTION(KeyedLoadIC_Miss) {
+RUNTIME_FUNCTION(Runtime_KeyedLoadIC_Miss) {
TimerEventScope<TimerEventIcMiss> timer(isolate);
HandleScope scope(isolate);
Handle<Object> receiver = args.at<Object>(0);
Handle<Object> key = args.at<Object>(1);
Handle<Object> result;
- if (FLAG_vector_ics) {
- DCHECK(args.length() == 4);
- Handle<Smi> slot = args.at<Smi>(2);
- Handle<TypeFeedbackVector> vector = args.at<TypeFeedbackVector>(3);
- FeedbackVectorICSlot vector_slot = vector->ToICSlot(slot->value());
- KeyedLoadICNexus nexus(vector, vector_slot);
- KeyedLoadIC ic(IC::NO_EXTRA_FRAME, isolate, &nexus);
- ic.UpdateState(receiver, key);
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, ic.Load(receiver, key));
- } else {
- DCHECK(args.length() == 2);
- KeyedLoadIC ic(IC::NO_EXTRA_FRAME, isolate);
- ic.UpdateState(receiver, key);
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, ic.Load(receiver, key));
- }
-
- return *result;
-}
-
-
-RUNTIME_FUNCTION(KeyedLoadIC_MissFromStubFailure) {
- TimerEventScope<TimerEventIcMiss> timer(isolate);
- HandleScope scope(isolate);
- Handle<Object> receiver = args.at<Object>(0);
- Handle<Object> key = args.at<Object>(1);
- Handle<Object> result;
-
- if (FLAG_vector_ics) {
- DCHECK(args.length() == 4);
- Handle<Smi> slot = args.at<Smi>(2);
- Handle<TypeFeedbackVector> vector = args.at<TypeFeedbackVector>(3);
- FeedbackVectorICSlot vector_slot = vector->ToICSlot(slot->value());
- KeyedLoadICNexus nexus(vector, vector_slot);
- KeyedLoadIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus);
- ic.UpdateState(receiver, key);
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, ic.Load(receiver, key));
- } else {
- DCHECK(args.length() == 2);
- KeyedLoadIC ic(IC::EXTRA_CALL_FRAME, isolate);
- ic.UpdateState(receiver, key);
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, ic.Load(receiver, key));
- }
-
- return *result;
-}
-
-
-// Used from ic-<arch>.cc.
-RUNTIME_FUNCTION(StoreIC_Miss) {
- TimerEventScope<TimerEventIcMiss> timer(isolate);
- HandleScope scope(isolate);
- DCHECK(args.length() == 3);
- StoreIC ic(IC::NO_EXTRA_FRAME, isolate);
- Handle<Object> receiver = args.at<Object>(0);
- Handle<Name> key = args.at<Name>(1);
- ic.UpdateState(receiver, key);
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result, ic.Store(receiver, key, args.at<Object>(2)));
- return *result;
-}
-
-
-RUNTIME_FUNCTION(StoreIC_MissFromStubFailure) {
- TimerEventScope<TimerEventIcMiss> timer(isolate);
- HandleScope scope(isolate);
- DCHECK(args.length() == 3 || args.length() == 4);
- StoreIC ic(IC::EXTRA_CALL_FRAME, isolate);
- Handle<Object> receiver = args.at<Object>(0);
- Handle<Name> key = args.at<Name>(1);
- ic.UpdateState(receiver, key);
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result, ic.Store(receiver, key, args.at<Object>(2)));
- return *result;
-}
-
-
-// Used from ic-<arch>.cc.
-RUNTIME_FUNCTION(KeyedStoreIC_Miss) {
- TimerEventScope<TimerEventIcMiss> timer(isolate);
- HandleScope scope(isolate);
- DCHECK(args.length() == 3);
- KeyedStoreIC ic(IC::NO_EXTRA_FRAME, isolate);
- Handle<Object> receiver = args.at<Object>(0);
- Handle<Object> key = args.at<Object>(1);
- ic.UpdateState(receiver, key);
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result, ic.Store(receiver, key, args.at<Object>(2)));
- return *result;
-}
-
-
-RUNTIME_FUNCTION(KeyedStoreIC_MissFromStubFailure) {
- TimerEventScope<TimerEventIcMiss> timer(isolate);
- HandleScope scope(isolate);
- DCHECK(args.length() == 3);
- KeyedStoreIC ic(IC::EXTRA_CALL_FRAME, isolate);
- Handle<Object> receiver = args.at<Object>(0);
- Handle<Object> key = args.at<Object>(1);
- ic.UpdateState(receiver, key);
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result, ic.Store(receiver, key, args.at<Object>(2)));
- return *result;
-}
-
-
-RUNTIME_FUNCTION(StoreIC_Slow) {
- HandleScope scope(isolate);
- DCHECK(args.length() == 3);
- StoreIC ic(IC::NO_EXTRA_FRAME, isolate);
- Handle<Object> object = args.at<Object>(0);
- Handle<Object> key = args.at<Object>(1);
- Handle<Object> value = args.at<Object>(2);
- StrictMode strict_mode = ic.strict_mode();
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result,
- Runtime::SetObjectProperty(isolate, object, key, value, strict_mode));
- return *result;
-}
-
-
-RUNTIME_FUNCTION(KeyedStoreIC_Slow) {
- HandleScope scope(isolate);
- DCHECK(args.length() == 3);
- KeyedStoreIC ic(IC::NO_EXTRA_FRAME, isolate);
- Handle<Object> object = args.at<Object>(0);
- Handle<Object> key = args.at<Object>(1);
- Handle<Object> value = args.at<Object>(2);
- StrictMode strict_mode = ic.strict_mode();
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result,
- Runtime::SetObjectProperty(isolate, object, key, value, strict_mode));
- return *result;
-}
-
-
-RUNTIME_FUNCTION(ElementsTransitionAndStoreIC_Miss) {
- TimerEventScope<TimerEventIcMiss> timer(isolate);
- HandleScope scope(isolate);
DCHECK(args.length() == 4);
- KeyedStoreIC ic(IC::EXTRA_CALL_FRAME, isolate);
- Handle<Object> value = args.at<Object>(0);
- Handle<Map> map = args.at<Map>(1);
- Handle<Object> key = args.at<Object>(2);
- Handle<Object> object = args.at<Object>(3);
- StrictMode strict_mode = ic.strict_mode();
+ Handle<Smi> slot = args.at<Smi>(2);
+ Handle<TypeFeedbackVector> vector = args.at<TypeFeedbackVector>(3);
+ FeedbackVectorSlot vector_slot = vector->ToSlot(slot->value());
+ KeyedLoadICNexus nexus(vector, vector_slot);
+ KeyedLoadIC ic(IC::NO_EXTRA_FRAME, isolate, &nexus);
+ ic.UpdateState(receiver, key);
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, ic.Load(receiver, key));
+ return *result;
+}
+
+
+RUNTIME_FUNCTION(Runtime_KeyedLoadIC_MissFromStubFailure) {
+ TimerEventScope<TimerEventIcMiss> timer(isolate);
+ HandleScope scope(isolate);
+ Handle<Object> receiver = args.at<Object>(0);
+ Handle<Object> key = args.at<Object>(1);
+ Handle<Object> result;
+
+ DCHECK(args.length() == 4);
+ Handle<Smi> slot = args.at<Smi>(2);
+ Handle<TypeFeedbackVector> vector = args.at<TypeFeedbackVector>(3);
+ FeedbackVectorSlot vector_slot = vector->ToSlot(slot->value());
+ KeyedLoadICNexus nexus(vector, vector_slot);
+ KeyedLoadIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus);
+ ic.UpdateState(receiver, key);
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, ic.Load(receiver, key));
+
+ return *result;
+}
+
+
+// Used from ic-<arch>.cc.
+RUNTIME_FUNCTION(Runtime_StoreIC_Miss) {
+ TimerEventScope<TimerEventIcMiss> timer(isolate);
+ HandleScope scope(isolate);
+ Handle<Object> receiver = args.at<Object>(0);
+ Handle<Name> key = args.at<Name>(1);
+ Handle<Object> value = args.at<Object>(2);
+ Handle<Object> result;
+
+ DCHECK(args.length() == 5 || args.length() == 6);
+ Handle<Smi> slot = args.at<Smi>(3);
+ Handle<TypeFeedbackVector> vector = args.at<TypeFeedbackVector>(4);
+ FeedbackVectorSlot vector_slot = vector->ToSlot(slot->value());
+ if (vector->GetKind(vector_slot) == FeedbackVectorSlotKind::STORE_IC) {
+ StoreICNexus nexus(vector, vector_slot);
+ StoreIC ic(IC::NO_EXTRA_FRAME, isolate, &nexus);
+ ic.UpdateState(receiver, key);
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
+ ic.Store(receiver, key, value));
+ } else {
+ DCHECK_EQ(FeedbackVectorSlotKind::KEYED_STORE_IC,
+ vector->GetKind(vector_slot));
+ KeyedStoreICNexus nexus(vector, vector_slot);
+ KeyedStoreIC ic(IC::NO_EXTRA_FRAME, isolate, &nexus);
+ ic.UpdateState(receiver, key);
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
+ ic.Store(receiver, key, value));
+ }
+ return *result;
+}
+
+
+RUNTIME_FUNCTION(Runtime_StoreIC_MissFromStubFailure) {
+ TimerEventScope<TimerEventIcMiss> timer(isolate);
+ HandleScope scope(isolate);
+ Handle<Object> receiver = args.at<Object>(0);
+ Handle<Name> key = args.at<Name>(1);
+ Handle<Object> value = args.at<Object>(2);
+ Handle<Object> result;
+
+ int length = args.length();
+ DCHECK(length == 5 || length == 6);
+ // We might have slot and vector, for a normal miss (slot(3), vector(4)).
+ // Or, map and vector for a transitioning store miss (map(3), vector(4)).
+ // In this case, we need to recover the slot from a virtual register.
+ // If length == 6, then a map is included (map(3), slot(4), vector(5)).
+ Handle<Smi> slot;
+ Handle<TypeFeedbackVector> vector;
+ if (length == 5) {
+ if (args.at<Object>(3)->IsMap()) {
+ vector = args.at<TypeFeedbackVector>(4);
+ slot = handle(
+ *reinterpret_cast<Smi**>(isolate->virtual_slot_register_address()),
+ isolate);
+ } else {
+ vector = args.at<TypeFeedbackVector>(4);
+ slot = args.at<Smi>(3);
+ }
+ } else {
+ vector = args.at<TypeFeedbackVector>(5);
+ slot = args.at<Smi>(4);
+ }
+
+ FeedbackVectorSlot vector_slot = vector->ToSlot(slot->value());
+ if (vector->GetKind(vector_slot) == FeedbackVectorSlotKind::STORE_IC) {
+ StoreICNexus nexus(vector, vector_slot);
+ StoreIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus);
+ ic.UpdateState(receiver, key);
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
+ ic.Store(receiver, key, value));
+ } else {
+ DCHECK_EQ(FeedbackVectorSlotKind::KEYED_STORE_IC,
+ vector->GetKind(vector_slot));
+ KeyedStoreICNexus nexus(vector, vector_slot);
+ KeyedStoreIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus);
+ ic.UpdateState(receiver, key);
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
+ ic.Store(receiver, key, value));
+ }
+ return *result;
+}
+
+
+// Used from ic-<arch>.cc.
+RUNTIME_FUNCTION(Runtime_KeyedStoreIC_Miss) {
+ TimerEventScope<TimerEventIcMiss> timer(isolate);
+ HandleScope scope(isolate);
+ Handle<Object> receiver = args.at<Object>(0);
+ Handle<Object> key = args.at<Object>(1);
+ Handle<Object> value = args.at<Object>(2);
+ Handle<Object> result;
+
+ DCHECK(args.length() == 5);
+ Handle<Smi> slot = args.at<Smi>(3);
+ Handle<TypeFeedbackVector> vector = args.at<TypeFeedbackVector>(4);
+ FeedbackVectorSlot vector_slot = vector->ToSlot(slot->value());
+ KeyedStoreICNexus nexus(vector, vector_slot);
+ KeyedStoreIC ic(IC::NO_EXTRA_FRAME, isolate, &nexus);
+ ic.UpdateState(receiver, key);
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
+ ic.Store(receiver, key, value));
+ return *result;
+}
+
+
+RUNTIME_FUNCTION(Runtime_KeyedStoreIC_MissFromStubFailure) {
+ TimerEventScope<TimerEventIcMiss> timer(isolate);
+ HandleScope scope(isolate);
+ Handle<Object> receiver = args.at<Object>(0);
+ Handle<Object> key = args.at<Object>(1);
+ Handle<Object> value = args.at<Object>(2);
+ Handle<Object> result;
+
+ DCHECK(args.length() == 5);
+ Handle<Smi> slot = args.at<Smi>(3);
+ Handle<TypeFeedbackVector> vector = args.at<TypeFeedbackVector>(4);
+ FeedbackVectorSlot vector_slot = vector->ToSlot(slot->value());
+ KeyedStoreICNexus nexus(vector, vector_slot);
+ KeyedStoreIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus);
+ ic.UpdateState(receiver, key);
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
+ ic.Store(receiver, key, value));
+ return *result;
+}
+
+
+RUNTIME_FUNCTION(Runtime_StoreIC_Slow) {
+ HandleScope scope(isolate);
+ DCHECK(args.length() == 5);
+ Handle<Object> object = args.at<Object>(0);
+ Handle<Object> key = args.at<Object>(1);
+ Handle<Object> value = args.at<Object>(2);
+ LanguageMode language_mode;
+ StoreICNexus nexus(isolate);
+ StoreIC ic(IC::NO_EXTRA_FRAME, isolate, &nexus);
+ language_mode = ic.language_mode();
+ Handle<Object> result;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, result,
+ Runtime::SetObjectProperty(isolate, object, key, value, language_mode));
+ return *result;
+}
+
+
+RUNTIME_FUNCTION(Runtime_KeyedStoreIC_Slow) {
+ HandleScope scope(isolate);
+ DCHECK(args.length() == 5);
+ Handle<Object> object = args.at<Object>(0);
+ Handle<Object> key = args.at<Object>(1);
+ Handle<Object> value = args.at<Object>(2);
+ LanguageMode language_mode;
+ KeyedStoreICNexus nexus(isolate);
+ KeyedStoreIC ic(IC::NO_EXTRA_FRAME, isolate, &nexus);
+ language_mode = ic.language_mode();
+ Handle<Object> result;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, result,
+ Runtime::SetObjectProperty(isolate, object, key, value, language_mode));
+ return *result;
+}
+
+
+RUNTIME_FUNCTION(Runtime_ElementsTransitionAndStoreIC_Miss) {
+ TimerEventScope<TimerEventIcMiss> timer(isolate);
+ HandleScope scope(isolate);
+ // Length == 5 or 6, depending on whether the vector slot
+ // is passed in a virtual register or not.
+ DCHECK(args.length() == 5 || args.length() == 6);
+ Handle<Object> object = args.at<Object>(0);
+ Handle<Object> key = args.at<Object>(1);
+ Handle<Object> value = args.at<Object>(2);
+ Handle<Map> map = args.at<Map>(3);
+ LanguageMode language_mode;
+ KeyedStoreICNexus nexus(isolate);
+ KeyedStoreIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus);
+ language_mode = ic.language_mode();
if (object->IsJSObject()) {
JSObject::TransitionElementsKind(Handle<JSObject>::cast(object),
map->elements_kind());
@@ -2476,7 +2488,7 @@
Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result,
- Runtime::SetObjectProperty(isolate, object, key, value, strict_mode));
+ Runtime::SetObjectProperty(isolate, object, key, value, language_mode));
return *result;
}
@@ -2487,17 +2499,79 @@
BinaryOpICState state(isolate(), target()->extra_ic_state());
// Compute the actual result using the builtin for the binary operation.
- Object* builtin = isolate()->js_builtins_object()->javascript_builtin(
- TokenToJSBuiltin(state.op()));
- Handle<JSFunction> function = handle(JSFunction::cast(builtin), isolate());
Handle<Object> result;
- ASSIGN_RETURN_ON_EXCEPTION(
- isolate(), result, Execution::Call(isolate(), function, left, 1, &right),
- Object);
+ switch (state.op()) {
+ default:
+ UNREACHABLE();
+ case Token::ADD:
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate(), result,
+ Object::Add(isolate(), left, right, state.strength()), Object);
+ break;
+ case Token::SUB:
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate(), result,
+ Object::Subtract(isolate(), left, right, state.strength()), Object);
+ break;
+ case Token::MUL:
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate(), result,
+ Object::Multiply(isolate(), left, right, state.strength()), Object);
+ break;
+ case Token::DIV:
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate(), result,
+ Object::Divide(isolate(), left, right, state.strength()), Object);
+ break;
+ case Token::MOD:
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate(), result,
+ Object::Modulus(isolate(), left, right, state.strength()), Object);
+ break;
+ case Token::BIT_OR:
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate(), result,
+ Object::BitwiseOr(isolate(), left, right, state.strength()), Object);
+ break;
+ case Token::BIT_AND:
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate(), result,
+ Object::BitwiseAnd(isolate(), left, right, state.strength()), Object);
+ break;
+ case Token::BIT_XOR:
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate(), result,
+ Object::BitwiseXor(isolate(), left, right, state.strength()), Object);
+ break;
+ case Token::SAR:
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate(), result,
+ Object::ShiftRight(isolate(), left, right, state.strength()), Object);
+ break;
+ case Token::SHR:
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate(), result,
+ Object::ShiftRightLogical(isolate(), left, right, state.strength()),
+ Object);
+ break;
+ case Token::SHL:
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate(), result,
+ Object::ShiftLeft(isolate(), left, right, state.strength()), Object);
+ break;
+ }
+
+ // Do not try to update the target if the code was marked for lazy
+ // deoptimization. (Since we do not relocate addresses in these
+ // code objects, an attempt to access the target could fail.)
+ if (AddressIsDeoptimizedCode()) {
+ return result;
+ }
// Execution::Call can execute arbitrary JavaScript, hence potentially
// update the state of this very IC, so we must update the stored state.
UpdateTarget();
+
// Compute the new state.
BinaryOpICState old_state(isolate(), target()->extra_ic_state());
state.Update(left, right, result);
@@ -2522,7 +2596,7 @@
target = stub.GetCode();
// Sanity check the generic stub.
- DCHECK_EQ(NULL, target->FindFirstAllocationSite());
+ DCHECK_NULL(target->FindFirstAllocationSite());
}
set_target(*target);
@@ -2539,16 +2613,16 @@
// Patch the inlined smi code as necessary.
if (!old_state.UseInlinedSmiCode() && state.UseInlinedSmiCode()) {
- PatchInlinedSmiCode(address(), ENABLE_INLINED_SMI_CHECK);
+ PatchInlinedSmiCode(isolate(), address(), ENABLE_INLINED_SMI_CHECK);
} else if (old_state.UseInlinedSmiCode() && !state.UseInlinedSmiCode()) {
- PatchInlinedSmiCode(address(), DISABLE_INLINED_SMI_CHECK);
+ PatchInlinedSmiCode(isolate(), address(), DISABLE_INLINED_SMI_CHECK);
}
return result;
}
-RUNTIME_FUNCTION(BinaryOpIC_Miss) {
+RUNTIME_FUNCTION(Runtime_BinaryOpIC_Miss) {
TimerEventScope<TimerEventIcMiss> timer(isolate);
HandleScope scope(isolate);
DCHECK_EQ(2, args.length());
@@ -2563,7 +2637,7 @@
}
-RUNTIME_FUNCTION(BinaryOpIC_MissWithAllocationSite) {
+RUNTIME_FUNCTION(Runtime_BinaryOpIC_MissWithAllocationSite) {
TimerEventScope<TimerEventIcMiss> timer(isolate);
HandleScope scope(isolate);
DCHECK_EQ(3, args.length());
@@ -2580,8 +2654,9 @@
}
-Code* CompareIC::GetRawUninitialized(Isolate* isolate, Token::Value op) {
- CompareICStub stub(isolate, op, CompareICState::UNINITIALIZED,
+Code* CompareIC::GetRawUninitialized(Isolate* isolate, Token::Value op,
+ Strength strength) {
+ CompareICStub stub(isolate, op, strength, CompareICState::UNINITIALIZED,
CompareICState::UNINITIALIZED,
CompareICState::UNINITIALIZED);
Code* code = NULL;
@@ -2590,8 +2665,9 @@
}
-Handle<Code> CompareIC::GetUninitialized(Isolate* isolate, Token::Value op) {
- CompareICStub stub(isolate, op, CompareICState::UNINITIALIZED,
+Handle<Code> CompareIC::GetUninitialized(Isolate* isolate, Token::Value op,
+ Strength strength) {
+ CompareICStub stub(isolate, op, strength, CompareICState::UNINITIALIZED,
CompareICState::UNINITIALIZED,
CompareICState::UNINITIALIZED);
return stub.GetCode();
@@ -2608,10 +2684,11 @@
CompareICState::State state = CompareICState::TargetState(
old_stub.state(), old_stub.left(), old_stub.right(), op_,
HasInlinedSmiCode(address()), x, y);
- CompareICStub stub(isolate(), op_, new_left, new_right, state);
- if (state == CompareICState::KNOWN_OBJECT) {
+ CompareICStub stub(isolate(), op_, old_stub.strength(), new_left, new_right,
+ state);
+ if (state == CompareICState::KNOWN_RECEIVER) {
stub.set_known_map(
- Handle<Map>(Handle<JSObject>::cast(x)->map(), isolate()));
+ Handle<Map>(Handle<JSReceiver>::cast(x)->map(), isolate()));
}
Handle<Code> new_target = stub.GetCode();
set_target(*new_target);
@@ -2631,7 +2708,7 @@
// Activate inlined smi code.
if (old_stub.state() == CompareICState::UNINITIALIZED) {
- PatchInlinedSmiCode(address(), ENABLE_INLINED_SMI_CHECK);
+ PatchInlinedSmiCode(isolate(), address(), ENABLE_INLINED_SMI_CHECK);
}
return *new_target;
@@ -2639,7 +2716,7 @@
// Used from CompareICStub::GenerateMiss in code-stubs-<arch>.cc.
-RUNTIME_FUNCTION(CompareIC_Miss) {
+RUNTIME_FUNCTION(Runtime_CompareIC_Miss) {
TimerEventScope<TimerEventIcMiss> timer(isolate);
HandleScope scope(isolate);
DCHECK(args.length() == 3);
@@ -2648,8 +2725,7 @@
}
-void CompareNilIC::Clear(Address address, Code* target,
- ConstantPoolArray* constant_pool) {
+void CompareNilIC::Clear(Address address, Code* target, Address constant_pool) {
if (IsCleared(target)) return;
ExtraICState state = target->extra_ic_state();
@@ -2667,9 +2743,9 @@
Handle<Object> CompareNilIC::DoCompareNilSlow(Isolate* isolate, NilValue nil,
Handle<Object> object) {
if (object->IsNull() || object->IsUndefined()) {
- return handle(Smi::FromInt(true), isolate);
+ return isolate->factory()->true_value();
}
- return handle(Smi::FromInt(object->IsUndetectableObject()), isolate);
+ return isolate->factory()->ToBoolean(object->IsUndetectableObject());
}
@@ -2701,7 +2777,7 @@
}
-RUNTIME_FUNCTION(CompareNilIC_Miss) {
+RUNTIME_FUNCTION(Runtime_CompareNilIC_Miss) {
TimerEventScope<TimerEventIcMiss> timer(isolate);
HandleScope scope(isolate);
Handle<Object> object = args.at<Object>(0);
@@ -2710,64 +2786,23 @@
}
-RUNTIME_FUNCTION(Unreachable) {
+RUNTIME_FUNCTION(Runtime_Unreachable) {
UNREACHABLE();
CHECK(false);
return isolate->heap()->undefined_value();
}
-Builtins::JavaScript BinaryOpIC::TokenToJSBuiltin(Token::Value op) {
- switch (op) {
- default:
- UNREACHABLE();
- case Token::ADD:
- return Builtins::ADD;
- break;
- case Token::SUB:
- return Builtins::SUB;
- break;
- case Token::MUL:
- return Builtins::MUL;
- break;
- case Token::DIV:
- return Builtins::DIV;
- break;
- case Token::MOD:
- return Builtins::MOD;
- break;
- case Token::BIT_OR:
- return Builtins::BIT_OR;
- break;
- case Token::BIT_AND:
- return Builtins::BIT_AND;
- break;
- case Token::BIT_XOR:
- return Builtins::BIT_XOR;
- break;
- case Token::SAR:
- return Builtins::SAR;
- break;
- case Token::SHR:
- return Builtins::SHR;
- break;
- case Token::SHL:
- return Builtins::SHL;
- break;
- }
-}
-
-
Handle<Object> ToBooleanIC::ToBoolean(Handle<Object> object) {
ToBooleanStub stub(isolate(), target()->extra_ic_state());
bool to_boolean_value = stub.UpdateStatus(object);
Handle<Code> code = stub.GetCode();
set_target(*code);
- return handle(Smi::FromInt(to_boolean_value ? 1 : 0), isolate());
+ return isolate()->factory()->ToBoolean(to_boolean_value);
}
-RUNTIME_FUNCTION(ToBooleanIC_Miss) {
+RUNTIME_FUNCTION(Runtime_ToBooleanIC_Miss) {
TimerEventScope<TimerEventIcMiss> timer(isolate);
DCHECK(args.length() == 1);
HandleScope scope(isolate);
@@ -2777,14 +2812,20 @@
}
-RUNTIME_FUNCTION(StoreCallbackProperty) {
+RUNTIME_FUNCTION(Runtime_StoreCallbackProperty) {
Handle<JSObject> receiver = args.at<JSObject>(0);
Handle<JSObject> holder = args.at<JSObject>(1);
- Handle<ExecutableAccessorInfo> callback = args.at<ExecutableAccessorInfo>(2);
+ Handle<HeapObject> callback_or_cell = args.at<HeapObject>(2);
Handle<Name> name = args.at<Name>(3);
Handle<Object> value = args.at<Object>(4);
HandleScope scope(isolate);
+ Handle<ExecutableAccessorInfo> callback(
+ callback_or_cell->IsWeakCell()
+ ? ExecutableAccessorInfo::cast(
+ WeakCell::cast(*callback_or_cell)->value())
+ : ExecutableAccessorInfo::cast(*callback_or_cell));
+
DCHECK(callback->IsCompatibleReceiver(*receiver));
Address setter_address = v8::ToCData<Address>(callback->setter());
@@ -2808,57 +2849,22 @@
* Returns |Heap::no_interceptor_result_sentinel()| if interceptor doesn't
* provide any value for the given name.
*/
-RUNTIME_FUNCTION(LoadPropertyWithInterceptorOnly) {
+RUNTIME_FUNCTION(Runtime_LoadPropertyWithInterceptorOnly) {
DCHECK(args.length() == NamedLoadHandlerCompiler::kInterceptorArgsLength);
Handle<Name> name =
args.at<Name>(NamedLoadHandlerCompiler::kInterceptorArgsNameIndex);
- Handle<InterceptorInfo> interceptor_info = args.at<InterceptorInfo>(
- NamedLoadHandlerCompiler::kInterceptorArgsInfoIndex);
-
- if (name->IsSymbol() && !interceptor_info->can_intercept_symbols())
- return isolate->heap()->no_interceptor_result_sentinel();
-
- Address getter_address = v8::ToCData<Address>(interceptor_info->getter());
- v8::GenericNamedPropertyGetterCallback getter =
- FUNCTION_CAST<v8::GenericNamedPropertyGetterCallback>(getter_address);
- DCHECK(getter != NULL);
-
Handle<JSObject> receiver =
args.at<JSObject>(NamedLoadHandlerCompiler::kInterceptorArgsThisIndex);
Handle<JSObject> holder =
args.at<JSObject>(NamedLoadHandlerCompiler::kInterceptorArgsHolderIndex);
- PropertyCallbackArguments callback_args(isolate, interceptor_info->data(),
- *receiver, *holder);
- {
- // Use the interceptor getter.
- HandleScope scope(isolate);
- v8::Handle<v8::Value> r =
- callback_args.Call(getter, v8::Utils::ToLocal(name));
- RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate);
- if (!r.IsEmpty()) {
- Handle<Object> result = v8::Utils::OpenHandle(*r);
- result->VerifyApiCallResultType();
- return *v8::Utils::OpenHandle(*r);
- }
- }
-
- return isolate->heap()->no_interceptor_result_sentinel();
-}
-
-
-static Object* ThrowReferenceError(Isolate* isolate, Name* name) {
- // If the load is non-contextual, just return the undefined result.
- // Note that both keyed and non-keyed loads may end up here.
HandleScope scope(isolate);
- LoadIC ic(IC::NO_EXTRA_FRAME, isolate, true);
- if (ic.contextual_mode() != CONTEXTUAL) {
- return isolate->heap()->undefined_value();
- }
-
- // Throw a reference error.
- Handle<Name> name_handle(name);
- THROW_NEW_ERROR_RETURN_FAILURE(
- isolate, NewReferenceError("not_defined", HandleVector(&name_handle, 1)));
+ LookupIterator it(receiver, name, holder, LookupIterator::OWN);
+ bool done;
+ Handle<Object> result;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, result, JSObject::GetPropertyWithInterceptor(&it, &done));
+ if (done) return *result;
+ return isolate->heap()->no_interceptor_result_sentinel();
}
@@ -2866,7 +2872,7 @@
* Loads a property with an interceptor performing post interceptor
* lookup if interceptor failed.
*/
-RUNTIME_FUNCTION(LoadPropertyWithInterceptor) {
+RUNTIME_FUNCTION(Runtime_LoadPropertyWithInterceptor) {
HandleScope scope(isolate);
DCHECK(args.length() == NamedLoadHandlerCompiler::kInterceptorArgsLength);
Handle<Name> name =
@@ -2878,19 +2884,31 @@
Handle<Object> result;
LookupIterator it(receiver, name, holder);
+ // TODO(conradw): Investigate strong mode semantics for this.
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
JSObject::GetProperty(&it));
if (it.IsFound()) return *result;
- return ThrowReferenceError(isolate, Name::cast(args[0]));
+ // Return the undefined result if the reference error should not be thrown.
+ // Note that both keyed and non-keyed loads may end up here.
+ LoadICNexus nexus(isolate);
+ LoadIC ic(IC::NO_EXTRA_FRAME, isolate, &nexus);
+ if (!ic.ShouldThrowReferenceError(it.GetReceiver())) {
+ return isolate->heap()->undefined_value();
+ }
+
+ // Throw a reference error.
+ THROW_NEW_ERROR_RETURN_FAILURE(
+ isolate, NewReferenceError(MessageTemplate::kNotDefined, it.name()));
}
-RUNTIME_FUNCTION(StorePropertyWithInterceptor) {
+RUNTIME_FUNCTION(Runtime_StorePropertyWithInterceptor) {
HandleScope scope(isolate);
DCHECK(args.length() == 3);
- StoreIC ic(IC::NO_EXTRA_FRAME, isolate);
+ StoreICNexus nexus(isolate);
+ StoreIC ic(IC::NO_EXTRA_FRAME, isolate, &nexus);
Handle<JSObject> receiver = args.at<JSObject>(0);
Handle<Name> name = args.at<Name>(1);
Handle<Object> value = args.at<Object>(2);
@@ -2911,71 +2929,56 @@
Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result,
- JSObject::SetProperty(receiver, name, value, ic.strict_mode()));
+ JSObject::SetProperty(receiver, name, value, ic.language_mode()));
return *result;
}
-RUNTIME_FUNCTION(LoadElementWithInterceptor) {
+RUNTIME_FUNCTION(Runtime_LoadElementWithInterceptor) {
+ // TODO(verwaest): This should probably get the holder and receiver as input.
HandleScope scope(isolate);
Handle<JSObject> receiver = args.at<JSObject>(0);
DCHECK(args.smi_at(1) >= 0);
uint32_t index = args.smi_at(1);
Handle<Object> result;
+ // TODO(conradw): Investigate strong mode semantics for this.
+ LanguageMode language_mode = SLOPPY;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result,
- JSObject::GetElementWithInterceptor(receiver, receiver, index, true));
+ Object::GetElement(isolate, receiver, index, language_mode));
return *result;
}
-RUNTIME_FUNCTION(LoadIC_MissFromStubFailure) {
+RUNTIME_FUNCTION(Runtime_LoadIC_MissFromStubFailure) {
TimerEventScope<TimerEventIcMiss> timer(isolate);
HandleScope scope(isolate);
Handle<Object> receiver = args.at<Object>(0);
Handle<Name> key = args.at<Name>(1);
Handle<Object> result;
- if (FLAG_vector_ics) {
- DCHECK(args.length() == 4);
- Handle<Smi> slot = args.at<Smi>(2);
- Handle<TypeFeedbackVector> vector = args.at<TypeFeedbackVector>(3);
- FeedbackVectorICSlot vector_slot = vector->ToICSlot(slot->value());
- // A monomorphic or polymorphic KeyedLoadIC with a string key can call the
- // LoadIC miss handler if the handler misses. Since the vector Nexus is
- // set up outside the IC, handle that here.
- if (vector->GetKind(vector_slot) == Code::LOAD_IC) {
- LoadICNexus nexus(vector, vector_slot);
- LoadIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus);
- ic.UpdateState(receiver, key);
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
- ic.Load(receiver, key));
- } else {
- DCHECK(vector->GetKind(vector_slot) == Code::KEYED_LOAD_IC);
- KeyedLoadICNexus nexus(vector, vector_slot);
- KeyedLoadIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus);
- ic.UpdateState(receiver, key);
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
- ic.Load(receiver, key));
- }
+ DCHECK(args.length() == 4);
+ Handle<Smi> slot = args.at<Smi>(2);
+ Handle<TypeFeedbackVector> vector = args.at<TypeFeedbackVector>(3);
+ FeedbackVectorSlot vector_slot = vector->ToSlot(slot->value());
+ // A monomorphic or polymorphic KeyedLoadIC with a string key can call the
+ // LoadIC miss handler if the handler misses. Since the vector Nexus is
+ // set up outside the IC, handle that here.
+ if (vector->GetKind(vector_slot) == FeedbackVectorSlotKind::LOAD_IC) {
+ LoadICNexus nexus(vector, vector_slot);
+ LoadIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus);
+ ic.UpdateState(receiver, key);
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, ic.Load(receiver, key));
} else {
- DCHECK(args.length() == 2);
- LoadIC ic(IC::EXTRA_CALL_FRAME, isolate);
+ DCHECK_EQ(FeedbackVectorSlotKind::KEYED_LOAD_IC,
+ vector->GetKind(vector_slot));
+ KeyedLoadICNexus nexus(vector, vector_slot);
+ KeyedLoadIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus);
ic.UpdateState(receiver, key);
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, ic.Load(receiver, key));
}
return *result;
}
-
-
-static const Address IC_utilities[] = {
-#define ADDR(name) FUNCTION_ADDR(name),
- IC_UTIL_LIST(ADDR) NULL
-#undef ADDR
-};
-
-
-Address IC::AddressFromUtilityId(IC::UtilityId id) { return IC_utilities[id]; }
-}
-} // namespace v8::internal
+} // namespace internal
+} // namespace v8