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) {
}
static V8_INLINE bool CheckForName(Handle<String> name,
static V8_INLINE bool CheckForName(Handle<Name> name,
Handle<String> 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<String> name,
// If true, *object_offset contains offset of object field.
template <class T>
bool Accessors::IsJSObjectFieldAccessor(typename T::TypeHandle type,
Handle<String> name,
Handle<Name> 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* type,
Handle<String> name,
Handle<Name> name,
int* object_offset);
template
bool Accessors::IsJSObjectFieldAccessor<HeapType>(Handle<HeapType> type,
Handle<String> name,
Handle<Name> name,
int* object_offset);
......
......@@ -78,7 +78,7 @@ class Accessors : public AllStatic {
// If true, *object_offset contains offset of object field.
template <class T>
static bool IsJSObjectFieldAccessor(typename T::TypeHandle type,
Handle<String> name,
Handle<Name> name,
int* object_offset);
static Handle<AccessorInfo> MakeAccessor(
......
......@@ -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());
Handle<Object> error = isolate()->factory()->NewReferenceError(
type, HandleVector(&name, 1));
......@@ -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
// 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<String> name, Handle<Code> code) {
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();
......@@ -766,7 +766,7 @@ template
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());
Handle<Code> ic = PropertyICCompiler::ComputeMonomorphic(
kind(), name, receiver_type(), handler, extra_ic_state());
......@@ -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;
CodeHandleList handlers;
TargetTypes(&types);
......@@ -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()) {
case UNINITIALIZED:
case PREMONOMORPHIC:
......@@ -873,7 +873,7 @@ Handle<Code> LoadIC::SimpleFieldLoad(FieldIndex index) {
void LoadIC::UpdateCaches(LookupIterator* lookup, Handle<Object> object,
Handle<String> name) {
Handle<Name> 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<Code> IC::ComputeHandler(LookupIterator* lookup, Handle<Object> object,
Handle<String> name, Handle<Object> value) {
Handle<Name> name, Handle<Object> value) {
bool receiver_is_holder =
object.is_identical_to(lookup->GetHolder<JSObject>());
CacheHolderFlag flag;
......@@ -957,7 +957,7 @@ Handle<Code> IC::ComputeHandler(LookupIterator* lookup, Handle<Object> object,
Handle<Code> IC::ComputeStoreHandler(LookupResult* lookup,
Handle<Object> object, Handle<String> name,
Handle<Object> object, Handle<Name> name,
Handle<Object> value) {
bool receiver_is_holder = lookup->ReceiverIsHolder(object);
CacheHolderFlag flag;
......@@ -1001,24 +1001,24 @@ Handle<Code> IC::ComputeStoreHandler(LookupResult* lookup,
Handle<Code> LoadIC::CompileHandler(LookupIterator* lookup,
Handle<Object> object, Handle<String> name,
Handle<Object> object, Handle<Name> name,
Handle<Object> 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<JSFunction>::cast(object)->should_have_prototype() &&
!Handle<JSFunction>::cast(object)->map()->has_non_instance_prototype()) {
Handle<Code> stub;
......@@ -1237,11 +1237,11 @@ MaybeHandle<Object> KeyedLoadIC::Load(Handle<Object> 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<String>::cast(key)),
LoadIC::Load(object, Handle<Name>::cast(key)),
Object);
} else if (FLAG_use_ic && !object->IsAccessCheckNeeded()) {
if (object->IsString() && key->IsNumber()) {
......@@ -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) {
// Disable ICs for non-JSObjects for now.
if (!object->IsJSObject()) return false;
......@@ -1348,7 +1348,7 @@ static bool LookupForWrite(Handle<Object> object, Handle<String> name,
MaybeHandle<Object> StoreIC::Store(Handle<Object> object,
Handle<String> name,
Handle<Name> name,
Handle<Object> value,
JSReceiver::StoreFromKeyed store_mode) {
// TODO(verwaest): Let SetProperty do the migration, since storing a property
......@@ -1473,7 +1473,7 @@ Handle<Code> StoreIC::pre_monomorphic_stub(Isolate* isolate,
void StoreIC::UpdateCaches(LookupResult* lookup,
Handle<JSObject> receiver,
Handle<String> name,
Handle<Name> name,
Handle<Object> value) {
DCHECK(lookup->IsFound());
......@@ -1489,7 +1489,7 @@ void StoreIC::UpdateCaches(LookupResult* lookup,
Handle<Code> StoreIC::CompileStoreHandler(LookupResult* lookup,
Handle<Object> object,
Handle<String> name,
Handle<Name> name,
Handle<Object> value,
CacheHolderFlag cache_holder) {
if (object->IsAccessCheckNeeded()) return slow_stub();
......
......@@ -169,7 +169,7 @@ class IC {
MaybeHandle<Object> TypeError(const char* type,
Handle<Object> object,
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.
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<Code> ComputeHandler(LookupIterator* lookup, Handle<Object> object,
Handle<String> name,
Handle<Name> name,
Handle<Object> value = Handle<Code>::null());
virtual Handle<Code> CompileHandler(LookupIterator* lookup,
Handle<Object> object,
Handle<String> name, Handle<Object> value,
Handle<Name> name, Handle<Object> value,
CacheHolderFlag cache_holder) {
UNREACHABLE();
return Handle<Code>::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<Code> ComputeStoreHandler(LookupResult* lookup, Handle<Object> object,
Handle<String> name,
Handle<Name> name,
Handle<Object> value = Handle<Code>::null());
virtual Handle<Code> CompileStoreHandler(LookupResult* lookup,
Handle<Object> object,
Handle<String> name,
Handle<Name> name,
Handle<Object> value,
CacheHolderFlag cache_holder) {
UNREACHABLE();
return Handle<Code>::null();
}
void UpdateMonomorphicIC(Handle<Code> handler, Handle<String> name);
bool UpdatePolymorphicIC(Handle<String> name, Handle<Code> code);
void UpdateMonomorphicIC(Handle<Code> handler, Handle<Name> name);
bool UpdatePolymorphicIC(Handle<Name> name, Handle<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);
void PatchCache(Handle<String> name, Handle<Code> code);
void PatchCache(Handle<Name> name, Handle<Code> 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<Object> Load(Handle<Object> object,
Handle<String> name);
Handle<Name> 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> object,
Handle<String> name);
Handle<Name> name);
virtual Handle<Code> CompileHandler(LookupIterator* lookup,
Handle<Object> object,
Handle<String> name,
Handle<Name> name,
Handle<Object> unused,
CacheHolderFlag cache_holder);
......@@ -628,7 +628,7 @@ class StoreIC: public IC {
MUST_USE_RESULT MaybeHandle<Object> Store(
Handle<Object> object,
Handle<String> name,
Handle<Name> name,
Handle<Object> 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<JSObject> receiver,
Handle<String> name,
Handle<Name> name,
Handle<Object> value);
virtual Handle<Code> CompileStoreHandler(LookupResult* lookup,
Handle<Object> object,
Handle<String> name,
Handle<Name> name,
Handle<Object> value,
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