From c08daece9950e77e7e7d4f81462d02c05157893b Mon Sep 17 00:00:00 2001 From: "dslomov@chromium.org" Date: Mon, 11 Aug 2014 12:57:25 +0000 Subject: [PATCH] Replace Strings with Names in load and store ICs. Mostly mechanical, the only interesting change is in KeyedLoadIC::Load, where we now handle x[symbol] in the same way we handle x['string'] R=verwaest@chromium.org Review URL: https://codereview.chromium.org/461603002 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23038 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/accessors.cc | 10 +++++----- src/accessors.h | 2 +- src/ic.cc | 38 +++++++++++++++++++------------------- src/ic.h | 30 +++++++++++++++--------------- 4 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/accessors.cc b/src/accessors.cc index 279b2b0..3875c4f 100644 --- a/src/accessors.cc +++ b/src/accessors.cc @@ -67,11 +67,11 @@ static C* FindInstanceOf(Isolate* isolate, Object* obj) { } -static V8_INLINE bool CheckForName(Handle name, +static V8_INLINE bool CheckForName(Handle name, Handle property_name, int offset, int* object_offset) { - if (String::Equals(name, property_name)) { + if (Name::Equals(name, property_name)) { *object_offset = offset; return true; } @@ -83,7 +83,7 @@ static V8_INLINE bool CheckForName(Handle name, // If true, *object_offset contains offset of object field. template bool Accessors::IsJSObjectFieldAccessor(typename T::TypeHandle type, - Handle name, + Handle name, int* object_offset) { Isolate* isolate = name->GetIsolate(); @@ -126,13 +126,13 @@ bool Accessors::IsJSObjectFieldAccessor(typename T::TypeHandle type, template bool Accessors::IsJSObjectFieldAccessor(Type* type, - Handle name, + Handle name, int* object_offset); template bool Accessors::IsJSObjectFieldAccessor(Handle type, - Handle name, + Handle name, int* object_offset); diff --git a/src/accessors.h b/src/accessors.h index a4195d8..17b7510 100644 --- a/src/accessors.h +++ b/src/accessors.h @@ -78,7 +78,7 @@ class Accessors : public AllStatic { // If true, *object_offset contains offset of object field. template static bool IsJSObjectFieldAccessor(typename T::TypeHandle type, - Handle name, + Handle name, int* object_offset); static Handle MakeAccessor( diff --git a/src/ic.cc b/src/ic.cc index 2139d5c..db82bf5 100644 --- a/src/ic.cc +++ b/src/ic.cc @@ -338,7 +338,7 @@ MaybeHandle IC::TypeError(const char* type, } -MaybeHandle IC::ReferenceError(const char* type, Handle name) { +MaybeHandle IC::ReferenceError(const char* type, Handle name) { HandleScope scope(isolate()); Handle error = isolate()->factory()->NewReferenceError( type, HandleVector(&name, 1)); @@ -590,7 +590,7 @@ static bool MigrateDeprecated(Handle object) { } -MaybeHandle LoadIC::Load(Handle object, Handle name) { +MaybeHandle LoadIC::Load(Handle object, Handle name) { // 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()) { @@ -660,7 +660,7 @@ static bool AddOneReceiverMapIfMissing(MapHandleList* receiver_maps, } -bool IC::UpdatePolymorphicIC(Handle name, Handle code) { +bool IC::UpdatePolymorphicIC(Handle name, Handle code) { if (!code->is_handler()) return false; if (target()->is_keyed_stub() && state() != PROTOTYPE_FAILURE) return false; Handle type = receiver_type(); @@ -766,7 +766,7 @@ template Handle IC::MapToType(Handle map, Isolate* region); -void IC::UpdateMonomorphicIC(Handle handler, Handle name) { +void IC::UpdateMonomorphicIC(Handle handler, Handle name) { DCHECK(handler->is_handler()); Handle ic = PropertyICCompiler::ComputeMonomorphic( kind(), name, receiver_type(), handler, extra_ic_state()); @@ -774,7 +774,7 @@ void IC::UpdateMonomorphicIC(Handle handler, Handle name) { } -void IC::CopyICToMegamorphicCache(Handle name) { +void IC::CopyICToMegamorphicCache(Handle name) { TypeHandleList types; CodeHandleList handlers; TargetTypes(&types); @@ -800,7 +800,7 @@ bool IC::IsTransitionOfMonomorphicTarget(Map* source_map, Map* target_map) { } -void IC::PatchCache(Handle name, Handle code) { +void IC::PatchCache(Handle name, Handle code) { switch (state()) { case UNINITIALIZED: case PREMONOMORPHIC: @@ -873,7 +873,7 @@ Handle LoadIC::SimpleFieldLoad(FieldIndex index) { void LoadIC::UpdateCaches(LookupIterator* lookup, Handle object, - Handle name) { + Handle name) { if (state() == UNINITIALIZED) { // This is the first time we execute this inline cache. // Set the target to the pre monomorphic stub to delay @@ -913,7 +913,7 @@ void IC::UpdateMegamorphicCache(HeapType* type, Name* name, Code* code) { Handle IC::ComputeHandler(LookupIterator* lookup, Handle object, - Handle name, Handle value) { + Handle name, Handle value) { bool receiver_is_holder = object.is_identical_to(lookup->GetHolder()); CacheHolderFlag flag; @@ -957,7 +957,7 @@ Handle IC::ComputeHandler(LookupIterator* lookup, Handle object, Handle IC::ComputeStoreHandler(LookupResult* lookup, - Handle object, Handle name, + Handle object, Handle name, Handle value) { bool receiver_is_holder = lookup->ReceiverIsHolder(object); CacheHolderFlag flag; @@ -1001,24 +1001,24 @@ Handle IC::ComputeStoreHandler(LookupResult* lookup, Handle LoadIC::CompileHandler(LookupIterator* lookup, - Handle object, Handle name, + Handle object, Handle name, Handle unused, CacheHolderFlag cache_holder) { if (object->IsString() && - String::Equals(isolate()->factory()->length_string(), name)) { + Name::Equals(isolate()->factory()->length_string(), name)) { FieldIndex index = FieldIndex::ForInObjectOffset(String::kLengthOffset); return SimpleFieldLoad(index); } if (object->IsStringWrapper() && - String::Equals(isolate()->factory()->length_string(), name)) { + Name::Equals(isolate()->factory()->length_string(), name)) { StringLengthStub string_length_stub(isolate()); return string_length_stub.GetCode(); } // Use specialized code for getting prototype of functions. if (object->IsJSFunction() && - String::Equals(isolate()->factory()->prototype_string(), name) && + Name::Equals(isolate()->factory()->prototype_string(), name) && Handle::cast(object)->should_have_prototype() && !Handle::cast(object)->map()->has_non_instance_prototype()) { Handle stub; @@ -1237,11 +1237,11 @@ MaybeHandle KeyedLoadIC::Load(Handle object, // internalized string directly or is representable as a smi. key = TryConvertKey(key, isolate()); - if (key->IsInternalizedString()) { + if (key->IsInternalizedString() || key->IsSymbol()) { ASSIGN_RETURN_ON_EXCEPTION( isolate(), load_handle, - LoadIC::Load(object, Handle::cast(key)), + LoadIC::Load(object, Handle::cast(key)), Object); } else if (FLAG_use_ic && !object->IsAccessCheckNeeded()) { if (object->IsString() && key->IsNumber()) { @@ -1280,7 +1280,7 @@ MaybeHandle KeyedLoadIC::Load(Handle object, } -static bool LookupForWrite(Handle object, Handle name, +static bool LookupForWrite(Handle object, Handle name, Handle value, LookupResult* lookup, IC* ic) { // Disable ICs for non-JSObjects for now. if (!object->IsJSObject()) return false; @@ -1348,7 +1348,7 @@ static bool LookupForWrite(Handle object, Handle name, MaybeHandle StoreIC::Store(Handle object, - Handle name, + Handle name, Handle value, JSReceiver::StoreFromKeyed store_mode) { // TODO(verwaest): Let SetProperty do the migration, since storing a property @@ -1473,7 +1473,7 @@ Handle StoreIC::pre_monomorphic_stub(Isolate* isolate, void StoreIC::UpdateCaches(LookupResult* lookup, Handle receiver, - Handle name, + Handle name, Handle value) { DCHECK(lookup->IsFound()); @@ -1489,7 +1489,7 @@ void StoreIC::UpdateCaches(LookupResult* lookup, Handle StoreIC::CompileStoreHandler(LookupResult* lookup, Handle object, - Handle name, + Handle name, Handle value, CacheHolderFlag cache_holder) { if (object->IsAccessCheckNeeded()) return slow_stub(); diff --git a/src/ic.h b/src/ic.h index 9877168..eb844cf 100644 --- a/src/ic.h +++ b/src/ic.h @@ -169,7 +169,7 @@ class IC { MaybeHandle TypeError(const char* type, Handle object, Handle key); - MaybeHandle ReferenceError(const char* type, Handle name); + MaybeHandle ReferenceError(const char* type, Handle name); // Access the target code for the given IC address. static inline Code* GetTargetAtAddress(Address address, @@ -184,11 +184,11 @@ class IC { // Compute the handler either by compiling or by retrieving a cached version. Handle ComputeHandler(LookupIterator* lookup, Handle object, - Handle name, + Handle name, Handle value = Handle::null()); virtual Handle CompileHandler(LookupIterator* lookup, Handle object, - Handle name, Handle value, + Handle name, Handle value, CacheHolderFlag cache_holder) { UNREACHABLE(); return Handle::null(); @@ -196,24 +196,24 @@ class IC { // Temporary copy of the above, but using a LookupResult. // TODO(jkummerow): Migrate callers to LookupIterator and delete these. Handle ComputeStoreHandler(LookupResult* lookup, Handle object, - Handle name, + Handle name, Handle value = Handle::null()); virtual Handle CompileStoreHandler(LookupResult* lookup, Handle object, - Handle name, + Handle name, Handle value, CacheHolderFlag cache_holder) { UNREACHABLE(); return Handle::null(); } - void UpdateMonomorphicIC(Handle handler, Handle name); - bool UpdatePolymorphicIC(Handle name, Handle code); + void UpdateMonomorphicIC(Handle handler, Handle name); + bool UpdatePolymorphicIC(Handle name, Handle code); void UpdateMegamorphicCache(HeapType* type, Name* name, Code* code); - void CopyICToMegamorphicCache(Handle name); + void CopyICToMegamorphicCache(Handle name); bool IsTransitionOfMonomorphicTarget(Map* source_map, Map* target_map); - void PatchCache(Handle name, Handle code); + void PatchCache(Handle name, Handle code); Code::Kind kind() const { return kind_; } Code::Kind handler_kind() const { if (kind_ == Code::KEYED_LOAD_IC) return Code::LOAD_IC; @@ -469,7 +469,7 @@ class LoadIC: public IC { ExtraICState extra_state); MUST_USE_RESULT MaybeHandle Load(Handle object, - Handle name); + Handle name); protected: void set_target(Code* code) { @@ -494,11 +494,11 @@ class LoadIC: public IC { // Update the inline cache and the global stub cache based on the // lookup result. void UpdateCaches(LookupIterator* lookup, Handle object, - Handle name); + Handle name); virtual Handle CompileHandler(LookupIterator* lookup, Handle object, - Handle name, + Handle name, Handle unused, CacheHolderFlag cache_holder); @@ -628,7 +628,7 @@ class StoreIC: public IC { MUST_USE_RESULT MaybeHandle Store( Handle object, - Handle name, + Handle name, Handle value, JSReceiver::StoreFromKeyed store_mode = JSReceiver::CERTAINLY_NOT_STORE_FROM_KEYED); @@ -654,11 +654,11 @@ class StoreIC: public IC { // lookup result. void UpdateCaches(LookupResult* lookup, Handle receiver, - Handle name, + Handle name, Handle value); virtual Handle CompileStoreHandler(LookupResult* lookup, Handle object, - Handle name, + Handle name, Handle value, CacheHolderFlag cache_holder); -- 2.7.4