Commit c08daece authored by dslomov@chromium.org's avatar dslomov@chromium.org

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
parent 1efd68d9
...@@ -67,11 +67,11 @@ static C* FindInstanceOf(Isolate* isolate, Object* obj) { ...@@ -67,11 +67,11 @@ static C* FindInstanceOf(Isolate* isolate, Object* obj) {
} }
static V8_INLINE bool CheckForName(Handle<String> name, static V8_INLINE bool CheckForName(Handle<Name> name,
Handle<String> property_name, Handle<String> property_name,
int offset, int offset,
int* object_offset) { int* object_offset) {
if (String::Equals(name, property_name)) { if (Name::Equals(name, property_name)) {
*object_offset = offset; *object_offset = offset;
return true; return true;
} }
...@@ -83,7 +83,7 @@ static V8_INLINE bool CheckForName(Handle<String> name, ...@@ -83,7 +83,7 @@ static V8_INLINE bool CheckForName(Handle<String> name,
// If true, *object_offset contains offset of object field. // If true, *object_offset contains offset of object field.
template <class T> template <class T>
bool Accessors::IsJSObjectFieldAccessor(typename T::TypeHandle type, bool Accessors::IsJSObjectFieldAccessor(typename T::TypeHandle type,
Handle<String> name, Handle<Name> name,
int* object_offset) { int* object_offset) {
Isolate* isolate = name->GetIsolate(); Isolate* isolate = name->GetIsolate();
...@@ -126,13 +126,13 @@ bool Accessors::IsJSObjectFieldAccessor(typename T::TypeHandle type, ...@@ -126,13 +126,13 @@ bool Accessors::IsJSObjectFieldAccessor(typename T::TypeHandle type,
template template
bool Accessors::IsJSObjectFieldAccessor<Type>(Type* type, bool Accessors::IsJSObjectFieldAccessor<Type>(Type* type,
Handle<String> name, Handle<Name> name,
int* object_offset); int* object_offset);
template template
bool Accessors::IsJSObjectFieldAccessor<HeapType>(Handle<HeapType> type, bool Accessors::IsJSObjectFieldAccessor<HeapType>(Handle<HeapType> type,
Handle<String> name, Handle<Name> name,
int* object_offset); int* object_offset);
......
...@@ -78,7 +78,7 @@ class Accessors : public AllStatic { ...@@ -78,7 +78,7 @@ class Accessors : public AllStatic {
// If true, *object_offset contains offset of object field. // If true, *object_offset contains offset of object field.
template <class T> template <class T>
static bool IsJSObjectFieldAccessor(typename T::TypeHandle type, static bool IsJSObjectFieldAccessor(typename T::TypeHandle type,
Handle<String> name, Handle<Name> name,
int* object_offset); int* object_offset);
static Handle<AccessorInfo> MakeAccessor( static Handle<AccessorInfo> MakeAccessor(
......
...@@ -338,7 +338,7 @@ MaybeHandle<Object> IC::TypeError(const char* type, ...@@ -338,7 +338,7 @@ MaybeHandle<Object> IC::TypeError(const char* type,
} }
MaybeHandle<Object> IC::ReferenceError(const char* type, Handle<String> name) { MaybeHandle<Object> IC::ReferenceError(const char* type, Handle<Name> name) {
HandleScope scope(isolate()); HandleScope scope(isolate());
Handle<Object> error = isolate()->factory()->NewReferenceError( Handle<Object> error = isolate()->factory()->NewReferenceError(
type, HandleVector(&name, 1)); type, HandleVector(&name, 1));
...@@ -590,7 +590,7 @@ static bool MigrateDeprecated(Handle<Object> object) { ...@@ -590,7 +590,7 @@ static bool MigrateDeprecated(Handle<Object> object) {
} }
MaybeHandle<Object> LoadIC::Load(Handle<Object> object, Handle<String> name) { MaybeHandle<Object> LoadIC::Load(Handle<Object> object, Handle<Name> name) {
// If the object is undefined or null it's illegal to try to get any // If the object is undefined or null it's illegal to try to get any
// of its properties; throw a TypeError in that case. // of its properties; throw a TypeError in that case.
if (object->IsUndefined() || object->IsNull()) { if (object->IsUndefined() || object->IsNull()) {
...@@ -660,7 +660,7 @@ static bool AddOneReceiverMapIfMissing(MapHandleList* receiver_maps, ...@@ -660,7 +660,7 @@ static bool AddOneReceiverMapIfMissing(MapHandleList* receiver_maps,
} }
bool IC::UpdatePolymorphicIC(Handle<String> name, Handle<Code> code) { bool IC::UpdatePolymorphicIC(Handle<Name> name, Handle<Code> code) {
if (!code->is_handler()) return false; if (!code->is_handler()) return false;
if (target()->is_keyed_stub() && state() != PROTOTYPE_FAILURE) return false; if (target()->is_keyed_stub() && state() != PROTOTYPE_FAILURE) return false;
Handle<HeapType> type = receiver_type(); Handle<HeapType> type = receiver_type();
...@@ -766,7 +766,7 @@ template ...@@ -766,7 +766,7 @@ template
Handle<HeapType> IC::MapToType<HeapType>(Handle<Map> map, Isolate* region); Handle<HeapType> IC::MapToType<HeapType>(Handle<Map> map, Isolate* region);
void IC::UpdateMonomorphicIC(Handle<Code> handler, Handle<String> name) { void IC::UpdateMonomorphicIC(Handle<Code> handler, Handle<Name> name) {
DCHECK(handler->is_handler()); DCHECK(handler->is_handler());
Handle<Code> ic = PropertyICCompiler::ComputeMonomorphic( Handle<Code> ic = PropertyICCompiler::ComputeMonomorphic(
kind(), name, receiver_type(), handler, extra_ic_state()); kind(), name, receiver_type(), handler, extra_ic_state());
...@@ -774,7 +774,7 @@ void IC::UpdateMonomorphicIC(Handle<Code> handler, Handle<String> name) { ...@@ -774,7 +774,7 @@ void IC::UpdateMonomorphicIC(Handle<Code> handler, Handle<String> name) {
} }
void IC::CopyICToMegamorphicCache(Handle<String> name) { void IC::CopyICToMegamorphicCache(Handle<Name> name) {
TypeHandleList types; TypeHandleList types;
CodeHandleList handlers; CodeHandleList handlers;
TargetTypes(&types); TargetTypes(&types);
...@@ -800,7 +800,7 @@ bool IC::IsTransitionOfMonomorphicTarget(Map* source_map, Map* target_map) { ...@@ -800,7 +800,7 @@ bool IC::IsTransitionOfMonomorphicTarget(Map* source_map, Map* target_map) {
} }
void IC::PatchCache(Handle<String> name, Handle<Code> code) { void IC::PatchCache(Handle<Name> name, Handle<Code> code) {
switch (state()) { switch (state()) {
case UNINITIALIZED: case UNINITIALIZED:
case PREMONOMORPHIC: case PREMONOMORPHIC:
...@@ -873,7 +873,7 @@ Handle<Code> LoadIC::SimpleFieldLoad(FieldIndex index) { ...@@ -873,7 +873,7 @@ Handle<Code> LoadIC::SimpleFieldLoad(FieldIndex index) {
void LoadIC::UpdateCaches(LookupIterator* lookup, Handle<Object> object, void LoadIC::UpdateCaches(LookupIterator* lookup, Handle<Object> object,
Handle<String> name) { Handle<Name> name) {
if (state() == UNINITIALIZED) { if (state() == UNINITIALIZED) {
// This is the first time we execute this inline cache. // This is the first time we execute this inline cache.
// Set the target to the pre monomorphic stub to delay // Set the target to the pre monomorphic stub to delay
...@@ -913,7 +913,7 @@ void IC::UpdateMegamorphicCache(HeapType* type, Name* name, Code* code) { ...@@ -913,7 +913,7 @@ void IC::UpdateMegamorphicCache(HeapType* type, Name* name, Code* code) {
Handle<Code> IC::ComputeHandler(LookupIterator* lookup, Handle<Object> object, Handle<Code> IC::ComputeHandler(LookupIterator* lookup, Handle<Object> object,
Handle<String> name, Handle<Object> value) { Handle<Name> name, Handle<Object> value) {
bool receiver_is_holder = bool receiver_is_holder =
object.is_identical_to(lookup->GetHolder<JSObject>()); object.is_identical_to(lookup->GetHolder<JSObject>());
CacheHolderFlag flag; CacheHolderFlag flag;
...@@ -957,7 +957,7 @@ Handle<Code> IC::ComputeHandler(LookupIterator* lookup, Handle<Object> object, ...@@ -957,7 +957,7 @@ Handle<Code> IC::ComputeHandler(LookupIterator* lookup, Handle<Object> object,
Handle<Code> IC::ComputeStoreHandler(LookupResult* lookup, Handle<Code> IC::ComputeStoreHandler(LookupResult* lookup,
Handle<Object> object, Handle<String> name, Handle<Object> object, Handle<Name> name,
Handle<Object> value) { Handle<Object> value) {
bool receiver_is_holder = lookup->ReceiverIsHolder(object); bool receiver_is_holder = lookup->ReceiverIsHolder(object);
CacheHolderFlag flag; CacheHolderFlag flag;
...@@ -1001,24 +1001,24 @@ Handle<Code> IC::ComputeStoreHandler(LookupResult* lookup, ...@@ -1001,24 +1001,24 @@ Handle<Code> IC::ComputeStoreHandler(LookupResult* lookup,
Handle<Code> LoadIC::CompileHandler(LookupIterator* lookup, Handle<Code> LoadIC::CompileHandler(LookupIterator* lookup,
Handle<Object> object, Handle<String> name, Handle<Object> object, Handle<Name> name,
Handle<Object> unused, Handle<Object> unused,
CacheHolderFlag cache_holder) { CacheHolderFlag cache_holder) {
if (object->IsString() && if (object->IsString() &&
String::Equals(isolate()->factory()->length_string(), name)) { Name::Equals(isolate()->factory()->length_string(), name)) {
FieldIndex index = FieldIndex::ForInObjectOffset(String::kLengthOffset); FieldIndex index = FieldIndex::ForInObjectOffset(String::kLengthOffset);
return SimpleFieldLoad(index); return SimpleFieldLoad(index);
} }
if (object->IsStringWrapper() && if (object->IsStringWrapper() &&
String::Equals(isolate()->factory()->length_string(), name)) { Name::Equals(isolate()->factory()->length_string(), name)) {
StringLengthStub string_length_stub(isolate()); StringLengthStub string_length_stub(isolate());
return string_length_stub.GetCode(); return string_length_stub.GetCode();
} }
// Use specialized code for getting prototype of functions. // Use specialized code for getting prototype of functions.
if (object->IsJSFunction() && if (object->IsJSFunction() &&
String::Equals(isolate()->factory()->prototype_string(), name) && Name::Equals(isolate()->factory()->prototype_string(), name) &&
Handle<JSFunction>::cast(object)->should_have_prototype() && Handle<JSFunction>::cast(object)->should_have_prototype() &&
!Handle<JSFunction>::cast(object)->map()->has_non_instance_prototype()) { !Handle<JSFunction>::cast(object)->map()->has_non_instance_prototype()) {
Handle<Code> stub; Handle<Code> stub;
...@@ -1237,11 +1237,11 @@ MaybeHandle<Object> KeyedLoadIC::Load(Handle<Object> object, ...@@ -1237,11 +1237,11 @@ MaybeHandle<Object> KeyedLoadIC::Load(Handle<Object> object,
// internalized string directly or is representable as a smi. // internalized string directly or is representable as a smi.
key = TryConvertKey(key, isolate()); key = TryConvertKey(key, isolate());
if (key->IsInternalizedString()) { if (key->IsInternalizedString() || key->IsSymbol()) {
ASSIGN_RETURN_ON_EXCEPTION( ASSIGN_RETURN_ON_EXCEPTION(
isolate(), isolate(),
load_handle, load_handle,
LoadIC::Load(object, Handle<String>::cast(key)), LoadIC::Load(object, Handle<Name>::cast(key)),
Object); Object);
} else if (FLAG_use_ic && !object->IsAccessCheckNeeded()) { } else if (FLAG_use_ic && !object->IsAccessCheckNeeded()) {
if (object->IsString() && key->IsNumber()) { if (object->IsString() && key->IsNumber()) {
...@@ -1280,7 +1280,7 @@ MaybeHandle<Object> KeyedLoadIC::Load(Handle<Object> object, ...@@ -1280,7 +1280,7 @@ MaybeHandle<Object> KeyedLoadIC::Load(Handle<Object> object,
} }
static bool LookupForWrite(Handle<Object> object, Handle<String> name, static bool LookupForWrite(Handle<Object> object, Handle<Name> name,
Handle<Object> value, LookupResult* lookup, IC* ic) { Handle<Object> value, LookupResult* lookup, IC* ic) {
// Disable ICs for non-JSObjects for now. // Disable ICs for non-JSObjects for now.
if (!object->IsJSObject()) return false; if (!object->IsJSObject()) return false;
...@@ -1348,7 +1348,7 @@ static bool LookupForWrite(Handle<Object> object, Handle<String> name, ...@@ -1348,7 +1348,7 @@ static bool LookupForWrite(Handle<Object> object, Handle<String> name,
MaybeHandle<Object> StoreIC::Store(Handle<Object> object, MaybeHandle<Object> StoreIC::Store(Handle<Object> object,
Handle<String> name, Handle<Name> name,
Handle<Object> value, Handle<Object> value,
JSReceiver::StoreFromKeyed store_mode) { JSReceiver::StoreFromKeyed store_mode) {
// TODO(verwaest): Let SetProperty do the migration, since storing a property // TODO(verwaest): Let SetProperty do the migration, since storing a property
...@@ -1473,7 +1473,7 @@ Handle<Code> StoreIC::pre_monomorphic_stub(Isolate* isolate, ...@@ -1473,7 +1473,7 @@ Handle<Code> StoreIC::pre_monomorphic_stub(Isolate* isolate,
void StoreIC::UpdateCaches(LookupResult* lookup, void StoreIC::UpdateCaches(LookupResult* lookup,
Handle<JSObject> receiver, Handle<JSObject> receiver,
Handle<String> name, Handle<Name> name,
Handle<Object> value) { Handle<Object> value) {
DCHECK(lookup->IsFound()); DCHECK(lookup->IsFound());
...@@ -1489,7 +1489,7 @@ void StoreIC::UpdateCaches(LookupResult* lookup, ...@@ -1489,7 +1489,7 @@ void StoreIC::UpdateCaches(LookupResult* lookup,
Handle<Code> StoreIC::CompileStoreHandler(LookupResult* lookup, Handle<Code> StoreIC::CompileStoreHandler(LookupResult* lookup,
Handle<Object> object, Handle<Object> object,
Handle<String> name, Handle<Name> name,
Handle<Object> value, Handle<Object> value,
CacheHolderFlag cache_holder) { CacheHolderFlag cache_holder) {
if (object->IsAccessCheckNeeded()) return slow_stub(); if (object->IsAccessCheckNeeded()) return slow_stub();
......
...@@ -169,7 +169,7 @@ class IC { ...@@ -169,7 +169,7 @@ class IC {
MaybeHandle<Object> TypeError(const char* type, MaybeHandle<Object> TypeError(const char* type,
Handle<Object> object, Handle<Object> object,
Handle<Object> key); Handle<Object> key);
MaybeHandle<Object> ReferenceError(const char* type, Handle<String> name); MaybeHandle<Object> ReferenceError(const char* type, Handle<Name> name);
// Access the target code for the given IC address. // Access the target code for the given IC address.
static inline Code* GetTargetAtAddress(Address address, static inline Code* GetTargetAtAddress(Address address,
...@@ -184,11 +184,11 @@ class IC { ...@@ -184,11 +184,11 @@ class IC {
// Compute the handler either by compiling or by retrieving a cached version. // Compute the handler either by compiling or by retrieving a cached version.
Handle<Code> ComputeHandler(LookupIterator* lookup, Handle<Object> object, Handle<Code> ComputeHandler(LookupIterator* lookup, Handle<Object> object,
Handle<String> name, Handle<Name> name,
Handle<Object> value = Handle<Code>::null()); Handle<Object> value = Handle<Code>::null());
virtual Handle<Code> CompileHandler(LookupIterator* lookup, virtual Handle<Code> CompileHandler(LookupIterator* lookup,
Handle<Object> object, Handle<Object> object,
Handle<String> name, Handle<Object> value, Handle<Name> name, Handle<Object> value,
CacheHolderFlag cache_holder) { CacheHolderFlag cache_holder) {
UNREACHABLE(); UNREACHABLE();
return Handle<Code>::null(); return Handle<Code>::null();
...@@ -196,24 +196,24 @@ class IC { ...@@ -196,24 +196,24 @@ class IC {
// Temporary copy of the above, but using a LookupResult. // Temporary copy of the above, but using a LookupResult.
// TODO(jkummerow): Migrate callers to LookupIterator and delete these. // TODO(jkummerow): Migrate callers to LookupIterator and delete these.
Handle<Code> ComputeStoreHandler(LookupResult* lookup, Handle<Object> object, Handle<Code> ComputeStoreHandler(LookupResult* lookup, Handle<Object> object,
Handle<String> name, Handle<Name> name,
Handle<Object> value = Handle<Code>::null()); Handle<Object> value = Handle<Code>::null());
virtual Handle<Code> CompileStoreHandler(LookupResult* lookup, virtual Handle<Code> CompileStoreHandler(LookupResult* lookup,
Handle<Object> object, Handle<Object> object,
Handle<String> name, Handle<Name> name,
Handle<Object> value, Handle<Object> value,
CacheHolderFlag cache_holder) { CacheHolderFlag cache_holder) {
UNREACHABLE(); UNREACHABLE();
return Handle<Code>::null(); return Handle<Code>::null();
} }
void UpdateMonomorphicIC(Handle<Code> handler, Handle<String> name); void UpdateMonomorphicIC(Handle<Code> handler, Handle<Name> name);
bool UpdatePolymorphicIC(Handle<String> name, Handle<Code> code); bool UpdatePolymorphicIC(Handle<Name> name, Handle<Code> code);
void UpdateMegamorphicCache(HeapType* type, Name* name, Code* code); void UpdateMegamorphicCache(HeapType* type, Name* name, Code* code);
void CopyICToMegamorphicCache(Handle<String> name); void CopyICToMegamorphicCache(Handle<Name> name);
bool IsTransitionOfMonomorphicTarget(Map* source_map, Map* target_map); bool IsTransitionOfMonomorphicTarget(Map* source_map, Map* target_map);
void PatchCache(Handle<String> name, Handle<Code> code); void PatchCache(Handle<Name> name, Handle<Code> code);
Code::Kind kind() const { return kind_; } Code::Kind kind() const { return kind_; }
Code::Kind handler_kind() const { Code::Kind handler_kind() const {
if (kind_ == Code::KEYED_LOAD_IC) return Code::LOAD_IC; if (kind_ == Code::KEYED_LOAD_IC) return Code::LOAD_IC;
...@@ -469,7 +469,7 @@ class LoadIC: public IC { ...@@ -469,7 +469,7 @@ class LoadIC: public IC {
ExtraICState extra_state); ExtraICState extra_state);
MUST_USE_RESULT MaybeHandle<Object> Load(Handle<Object> object, MUST_USE_RESULT MaybeHandle<Object> Load(Handle<Object> object,
Handle<String> name); Handle<Name> name);
protected: protected:
void set_target(Code* code) { void set_target(Code* code) {
...@@ -494,11 +494,11 @@ class LoadIC: public IC { ...@@ -494,11 +494,11 @@ class LoadIC: public IC {
// Update the inline cache and the global stub cache based on the // Update the inline cache and the global stub cache based on the
// lookup result. // lookup result.
void UpdateCaches(LookupIterator* lookup, Handle<Object> object, void UpdateCaches(LookupIterator* lookup, Handle<Object> object,
Handle<String> name); Handle<Name> name);
virtual Handle<Code> CompileHandler(LookupIterator* lookup, virtual Handle<Code> CompileHandler(LookupIterator* lookup,
Handle<Object> object, Handle<Object> object,
Handle<String> name, Handle<Name> name,
Handle<Object> unused, Handle<Object> unused,
CacheHolderFlag cache_holder); CacheHolderFlag cache_holder);
...@@ -628,7 +628,7 @@ class StoreIC: public IC { ...@@ -628,7 +628,7 @@ class StoreIC: public IC {
MUST_USE_RESULT MaybeHandle<Object> Store( MUST_USE_RESULT MaybeHandle<Object> Store(
Handle<Object> object, Handle<Object> object,
Handle<String> name, Handle<Name> name,
Handle<Object> value, Handle<Object> value,
JSReceiver::StoreFromKeyed store_mode = JSReceiver::StoreFromKeyed store_mode =
JSReceiver::CERTAINLY_NOT_STORE_FROM_KEYED); JSReceiver::CERTAINLY_NOT_STORE_FROM_KEYED);
...@@ -654,11 +654,11 @@ class StoreIC: public IC { ...@@ -654,11 +654,11 @@ class StoreIC: public IC {
// lookup result. // lookup result.
void UpdateCaches(LookupResult* lookup, void UpdateCaches(LookupResult* lookup,
Handle<JSObject> receiver, Handle<JSObject> receiver,
Handle<String> name, Handle<Name> name,
Handle<Object> value); Handle<Object> value);
virtual Handle<Code> CompileStoreHandler(LookupResult* lookup, virtual Handle<Code> CompileStoreHandler(LookupResult* lookup,
Handle<Object> object, Handle<Object> object,
Handle<String> name, Handle<Name> name,
Handle<Object> value, Handle<Object> value,
CacheHolderFlag cache_holder); CacheHolderFlag cache_holder);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment