diff options
Diffstat (limited to 'deps/v8/src/ic.cc')
-rw-r--r-- | deps/v8/src/ic.cc | 94 |
1 files changed, 46 insertions, 48 deletions
diff --git a/deps/v8/src/ic.cc b/deps/v8/src/ic.cc index 8fc9ddb86..31ece04a0 100644 --- a/deps/v8/src/ic.cc +++ b/deps/v8/src/ic.cc @@ -330,10 +330,11 @@ static void LookupForRead(Object* object, while (true) { object->Lookup(name, lookup); // Besides normal conditions (property not found or it's not - // an interceptor), bail out of lookup is not cacheable: we won't + // an interceptor), bail out if lookup is not cacheable: we won't // be able to IC it anyway and regular lookup should work fine. - if (lookup->IsNotFound() || lookup->type() != INTERCEPTOR || - !lookup->IsCacheable()) { + if (!lookup->IsFound() + || (lookup->type() != INTERCEPTOR) + || !lookup->IsCacheable()) { return; } @@ -343,7 +344,7 @@ static void LookupForRead(Object* object, } holder->LocalLookupRealNamedProperty(name, lookup); - if (lookup->IsValid()) { + if (lookup->IsProperty()) { ASSERT(lookup->type() != INTERCEPTOR); return; } @@ -422,7 +423,7 @@ Object* CallIC::LoadFunction(State state, LookupResult lookup; LookupForRead(*object, *name, &lookup); - if (!lookup.IsValid()) { + if (!lookup.IsProperty()) { // If the object does not have the requested property, check which // exception we need to throw. if (IsContextual(object)) { @@ -455,7 +456,7 @@ Object* CallIC::LoadFunction(State state, if (result->IsJSFunction()) { // Check if there is an optimized (builtin) version of the function. - // Ignored this will degrade performance for Array.prototype.{push,pop}. + // Ignored this will degrade performance for some Array functions. // Please note we only return the optimized function iff // the JSObject has FastElements. if (object->IsJSObject() && JSObject::cast(*object)->HasFastElements()) { @@ -493,7 +494,7 @@ void CallIC::UpdateCaches(LookupResult* lookup, Handle<String> name) { ASSERT(lookup->IsLoaded()); // Bail out if we didn't find a result. - if (!lookup->IsValid() || !lookup->IsCacheable()) return; + if (!lookup->IsProperty() || !lookup->IsCacheable()) return; // Compute the number of arguments. int argc = target()->arguments_count(); @@ -642,8 +643,8 @@ Object* LoadIC::Load(State state, Handle<Object> object, Handle<String> name) { LookupResult lookup; LookupForRead(*object, *name, &lookup); - // If lookup is invalid, check if we need to throw an exception. - if (!lookup.IsValid()) { + // If we did not find a property, check if we need to throw an exception. + if (!lookup.IsProperty()) { if (FLAG_strict || IsContextual(object)) { return ReferenceError("not_defined", name); } @@ -653,7 +654,7 @@ Object* LoadIC::Load(State state, Handle<Object> object, Handle<String> name) { bool can_be_inlined = FLAG_use_ic && state == PREMONOMORPHIC && - lookup.IsValid() && + lookup.IsProperty() && lookup.IsLoaded() && lookup.IsCacheable() && lookup.holder() == *object && @@ -681,7 +682,7 @@ Object* LoadIC::Load(State state, Handle<Object> object, Handle<String> name) { } PropertyAttributes attr; - if (lookup.IsValid() && lookup.type() == INTERCEPTOR) { + if (lookup.IsProperty() && lookup.type() == INTERCEPTOR) { // Get the property. Object* result = object->GetProperty(*object, &lookup, *name, &attr); if (result->IsFailure()) return result; @@ -704,7 +705,7 @@ void LoadIC::UpdateCaches(LookupResult* lookup, Handle<String> name) { ASSERT(lookup->IsLoaded()); // Bail out if we didn't find a result. - if (!lookup->IsValid() || !lookup->IsCacheable()) return; + if (!lookup->IsProperty() || !lookup->IsCacheable()) return; // Loading properties from values is not common, so don't try to // deal with non-JS objects here. @@ -857,8 +858,8 @@ Object* KeyedLoadIC::Load(State state, LookupResult lookup; LookupForRead(*object, *name, &lookup); - // If lookup is invalid, check if we need to throw an exception. - if (!lookup.IsValid()) { + // If we did not find a property, check if we need to throw an exception. + if (!lookup.IsProperty()) { if (FLAG_strict || IsContextual(object)) { return ReferenceError("not_defined", name); } @@ -869,7 +870,7 @@ Object* KeyedLoadIC::Load(State state, } PropertyAttributes attr; - if (lookup.IsValid() && lookup.type() == INTERCEPTOR) { + if (lookup.IsProperty() && lookup.type() == INTERCEPTOR) { // Get the property. Object* result = object->GetProperty(*object, &lookup, *name, &attr); if (result->IsFailure()) return result; @@ -896,6 +897,8 @@ Object* KeyedLoadIC::Load(State state, Handle<JSObject> receiver = Handle<JSObject>::cast(object); if (receiver->HasExternalArrayElements()) { stub = external_array_stub(receiver->GetElementsKind()); + } else if (receiver->HasIndexedInterceptor()) { + stub = indexed_interceptor_stub(); } } set_target(stub); @@ -919,7 +922,7 @@ void KeyedLoadIC::UpdateCaches(LookupResult* lookup, State state, Handle<Object> object, Handle<String> name) { ASSERT(lookup->IsLoaded()); // Bail out if we didn't find a result. - if (!lookup->IsValid() || !lookup->IsCacheable()) return; + if (!lookup->IsProperty() || !lookup->IsCacheable()) return; if (!object->IsJSObject()) return; Handle<JSObject> receiver = Handle<JSObject>::cast(object); @@ -992,7 +995,7 @@ void KeyedLoadIC::UpdateCaches(LookupResult* lookup, State state, static bool StoreICableLookup(LookupResult* lookup) { // Bail out if we didn't find a result. - if (!lookup->IsValid() || !lookup->IsCacheable()) return false; + if (!lookup->IsPropertyOrTransition() || !lookup->IsCacheable()) return false; // If the property is read-only, we leave the IC in its current // state. @@ -1046,6 +1049,20 @@ Object* StoreIC::Store(State state, return *value; } + + // Use specialized code for setting the length of arrays. + if (receiver->IsJSArray() + && name->Equals(Heap::length_symbol()) + && receiver->AllowsSetElementsLength()) { +#ifdef DEBUG + if (FLAG_trace_ic) PrintF("[StoreIC : +#length /array]\n"); +#endif + Code* target = Builtins::builtin(Builtins::StoreIC_ArrayLength); + set_target(target); + StubCache::Set(*name, HeapObject::cast(*object)->map(), target); + return receiver->SetProperty(*name, *value, NONE); + } + // Lookup the property locally in the receiver. if (FLAG_use_ic && !receiver->IsJSGlobalProxy()) { LookupResult lookup; @@ -1212,7 +1229,7 @@ void KeyedStoreIC::UpdateCaches(LookupResult* lookup, if (receiver->IsJSGlobalProxy()) return; // Bail out if we didn't find a result. - if (!lookup->IsValid() || !lookup->IsCacheable()) return; + if (!lookup->IsPropertyOrTransition() || !lookup->IsCacheable()) return; // If the property is read-only, we leave the IC in its current // state. @@ -1320,16 +1337,6 @@ Object* LoadIC_Miss(Arguments args) { } -void LoadIC::GenerateInitialize(MacroAssembler* masm) { - Generate(masm, ExternalReference(IC_Utility(kLoadIC_Miss))); -} - - -void LoadIC::GeneratePreMonomorphic(MacroAssembler* masm) { - Generate(masm, ExternalReference(IC_Utility(kLoadIC_Miss))); -} - - // Used from ic_<arch>.cc Object* KeyedLoadIC_Miss(Arguments args) { NoHandleAllocation na; @@ -1340,16 +1347,6 @@ Object* KeyedLoadIC_Miss(Arguments args) { } -void KeyedLoadIC::GenerateInitialize(MacroAssembler* masm) { - Generate(masm, ExternalReference(IC_Utility(kKeyedLoadIC_Miss))); -} - - -void KeyedLoadIC::GeneratePreMonomorphic(MacroAssembler* masm) { - Generate(masm, ExternalReference(IC_Utility(kKeyedLoadIC_Miss))); -} - - // Used from ic_<arch>.cc. Object* StoreIC_Miss(Arguments args) { NoHandleAllocation na; @@ -1361,6 +1358,17 @@ Object* StoreIC_Miss(Arguments args) { } +Object* StoreIC_ArrayLength(Arguments args) { + NoHandleAllocation nha; + + ASSERT(args.length() == 2); + JSObject* receiver = JSObject::cast(args[0]); + Object* len = args[1]; + + return receiver->SetElementsLength(len); +} + + // Extend storage is called in a store inline cache when // it is necessary to extend the properties array of a // JSObject. @@ -1406,16 +1414,6 @@ Object* KeyedStoreIC_Miss(Arguments args) { } -void KeyedStoreIC::GenerateInitialize(MacroAssembler* masm) { - Generate(masm, ExternalReference(IC_Utility(kKeyedStoreIC_Miss))); -} - - -void KeyedStoreIC::GenerateMiss(MacroAssembler* masm) { - Generate(masm, ExternalReference(IC_Utility(kKeyedStoreIC_Miss))); -} - - static Address IC_utilities[] = { #define ADDR(name) FUNCTION_ADDR(name), IC_UTIL_LIST(ADDR) |