Index: src/stub-cache.cc |
diff --git a/src/stub-cache.cc b/src/stub-cache.cc |
index e8f53a1bfcf57571e3b14ea9f43786828648878b..8aa59012ba2042fbf4da89d2f873f07f0956a2b0 100644 |
--- a/src/stub-cache.cc |
+++ b/src/stub-cache.cc |
@@ -56,14 +56,14 @@ void StubCache::Initialize() { |
} |
-Code* StubCache::Set(String* name, Map* map, Code* code) { |
+Code* StubCache::Set(Name* name, Map* map, Code* code) { |
// Get the flags from the code. |
Code::Flags flags = Code::RemoveTypeFromFlags(code->flags()); |
// Validate that the name does not move on scavenge, and that we |
- // can use identity checks instead of string equality checks. |
+ // can use identity checks instead of structural equality checks. |
ASSERT(!heap()->InNewSpace(name)); |
- ASSERT(name->IsInternalizedString()); |
+ ASSERT(name->IsUniqueName()); |
// The state bits are not important to the hash function because |
// the stub cache only contains monomorphic stubs. Make sure that |
@@ -100,7 +100,7 @@ Code* StubCache::Set(String* name, Map* map, Code* code) { |
} |
-Handle<Code> StubCache::ComputeLoadNonexistent(Handle<String> name, |
+Handle<Code> StubCache::ComputeLoadNonexistent(Handle<Name> name, |
Handle<JSObject> receiver) { |
// If no global objects are present in the prototype chain, the load |
// nonexistent IC stub can be shared for all names for a given map |
@@ -108,7 +108,7 @@ Handle<Code> StubCache::ComputeLoadNonexistent(Handle<String> name, |
// there are global objects involved, we need to check global |
// property cells in the stub and therefore the stub will be |
// specific to the name. |
- Handle<String> cache_name = factory()->empty_string(); |
+ Handle<Name> cache_name = factory()->empty_string(); |
Handle<JSObject> current; |
Handle<Object> next = receiver; |
Handle<GlobalObject> global; |
@@ -141,7 +141,7 @@ Handle<Code> StubCache::ComputeLoadNonexistent(Handle<String> name, |
} |
-Handle<Code> StubCache::ComputeLoadField(Handle<String> name, |
+Handle<Code> StubCache::ComputeLoadField(Handle<Name> name, |
Handle<JSObject> receiver, |
Handle<JSObject> holder, |
PropertyIndex field) { |
@@ -162,7 +162,7 @@ Handle<Code> StubCache::ComputeLoadField(Handle<String> name, |
} |
-Handle<Code> StubCache::ComputeLoadCallback(Handle<String> name, |
+Handle<Code> StubCache::ComputeLoadCallback(Handle<Name> name, |
Handle<JSObject> receiver, |
Handle<JSObject> holder, |
Handle<AccessorInfo> callback) { |
@@ -186,7 +186,7 @@ Handle<Code> StubCache::ComputeLoadCallback(Handle<String> name, |
} |
-Handle<Code> StubCache::ComputeLoadViaGetter(Handle<String> name, |
+Handle<Code> StubCache::ComputeLoadViaGetter(Handle<Name> name, |
Handle<JSObject> receiver, |
Handle<JSObject> holder, |
Handle<JSFunction> getter) { |
@@ -209,7 +209,7 @@ Handle<Code> StubCache::ComputeLoadViaGetter(Handle<String> name, |
} |
-Handle<Code> StubCache::ComputeLoadConstant(Handle<String> name, |
+Handle<Code> StubCache::ComputeLoadConstant(Handle<Name> name, |
Handle<JSObject> receiver, |
Handle<JSObject> holder, |
Handle<JSFunction> value) { |
@@ -232,7 +232,7 @@ Handle<Code> StubCache::ComputeLoadConstant(Handle<String> name, |
} |
-Handle<Code> StubCache::ComputeLoadInterceptor(Handle<String> name, |
+Handle<Code> StubCache::ComputeLoadInterceptor(Handle<Name> name, |
Handle<JSObject> receiver, |
Handle<JSObject> holder) { |
InlineCacheHolderFlag cache_holder = |
@@ -259,7 +259,7 @@ Handle<Code> StubCache::ComputeLoadNormal() { |
} |
-Handle<Code> StubCache::ComputeLoadGlobal(Handle<String> name, |
+Handle<Code> StubCache::ComputeLoadGlobal(Handle<Name> name, |
Handle<JSObject> receiver, |
Handle<GlobalObject> holder, |
Handle<JSGlobalPropertyCell> cell, |
@@ -283,7 +283,7 @@ Handle<Code> StubCache::ComputeLoadGlobal(Handle<String> name, |
} |
-Handle<Code> StubCache::ComputeKeyedLoadField(Handle<String> name, |
+Handle<Code> StubCache::ComputeKeyedLoadField(Handle<Name> name, |
Handle<JSObject> receiver, |
Handle<JSObject> holder, |
PropertyIndex field) { |
@@ -305,7 +305,7 @@ Handle<Code> StubCache::ComputeKeyedLoadField(Handle<String> name, |
} |
-Handle<Code> StubCache::ComputeKeyedLoadConstant(Handle<String> name, |
+Handle<Code> StubCache::ComputeKeyedLoadConstant(Handle<Name> name, |
Handle<JSObject> receiver, |
Handle<JSObject> holder, |
Handle<JSFunction> value) { |
@@ -328,7 +328,7 @@ Handle<Code> StubCache::ComputeKeyedLoadConstant(Handle<String> name, |
} |
-Handle<Code> StubCache::ComputeKeyedLoadInterceptor(Handle<String> name, |
+Handle<Code> StubCache::ComputeKeyedLoadInterceptor(Handle<Name> name, |
Handle<JSObject> receiver, |
Handle<JSObject> holder) { |
InlineCacheHolderFlag cache_holder = |
@@ -350,7 +350,7 @@ Handle<Code> StubCache::ComputeKeyedLoadInterceptor(Handle<String> name, |
Handle<Code> StubCache::ComputeKeyedLoadCallback( |
- Handle<String> name, |
+ Handle<Name> name, |
Handle<JSObject> receiver, |
Handle<JSObject> holder, |
Handle<AccessorInfo> callback) { |
@@ -373,7 +373,7 @@ Handle<Code> StubCache::ComputeKeyedLoadCallback( |
} |
-Handle<Code> StubCache::ComputeStoreField(Handle<String> name, |
+Handle<Code> StubCache::ComputeStoreField(Handle<Name> name, |
Handle<JSObject> receiver, |
int field_index, |
Handle<Map> transition, |
@@ -399,7 +399,7 @@ Handle<Code> StubCache::ComputeStoreField(Handle<String> name, |
Handle<Code> StubCache::ComputeKeyedLoadElement(Handle<Map> receiver_map) { |
Code::Flags flags = |
Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, Code::NORMAL); |
- Handle<String> name = |
+ Handle<Name> name = |
isolate()->factory()->KeyedLoadElementMonomorphic_string(); |
Handle<Object> probe(receiver_map->FindInCodeCache(*name, flags), isolate_); |
@@ -427,7 +427,7 @@ Handle<Code> StubCache::ComputeKeyedStoreElement( |
ASSERT(stub_kind == KeyedStoreIC::STORE_NO_TRANSITION || |
stub_kind == KeyedStoreIC::STORE_AND_GROW_NO_TRANSITION); |
- Handle<String> name = stub_kind == KeyedStoreIC::STORE_NO_TRANSITION |
+ Handle<Name> name = stub_kind == KeyedStoreIC::STORE_NO_TRANSITION |
? isolate()->factory()->KeyedStoreElementMonomorphic_string() |
: isolate()->factory()->KeyedStoreAndGrowElementMonomorphic_string(); |
@@ -450,7 +450,7 @@ Handle<Code> StubCache::ComputeStoreNormal(StrictModeFlag strict_mode) { |
} |
-Handle<Code> StubCache::ComputeStoreGlobal(Handle<String> name, |
+Handle<Code> StubCache::ComputeStoreGlobal(Handle<Name> name, |
Handle<GlobalObject> receiver, |
Handle<JSGlobalPropertyCell> cell, |
StrictModeFlag strict_mode) { |
@@ -469,7 +469,7 @@ Handle<Code> StubCache::ComputeStoreGlobal(Handle<String> name, |
} |
-Handle<Code> StubCache::ComputeStoreCallback(Handle<String> name, |
+Handle<Code> StubCache::ComputeStoreCallback(Handle<Name> name, |
Handle<JSObject> receiver, |
Handle<JSObject> holder, |
Handle<AccessorInfo> callback, |
@@ -491,7 +491,7 @@ Handle<Code> StubCache::ComputeStoreCallback(Handle<String> name, |
} |
-Handle<Code> StubCache::ComputeStoreViaSetter(Handle<String> name, |
+Handle<Code> StubCache::ComputeStoreViaSetter(Handle<Name> name, |
Handle<JSObject> receiver, |
Handle<JSObject> holder, |
Handle<JSFunction> setter, |
@@ -512,7 +512,7 @@ Handle<Code> StubCache::ComputeStoreViaSetter(Handle<String> name, |
} |
-Handle<Code> StubCache::ComputeStoreInterceptor(Handle<String> name, |
+Handle<Code> StubCache::ComputeStoreInterceptor(Handle<Name> name, |
Handle<JSObject> receiver, |
StrictModeFlag strict_mode) { |
Code::Flags flags = Code::ComputeMonomorphicFlags( |
@@ -529,7 +529,7 @@ Handle<Code> StubCache::ComputeStoreInterceptor(Handle<String> name, |
return code; |
} |
-Handle<Code> StubCache::ComputeKeyedStoreField(Handle<String> name, |
+Handle<Code> StubCache::ComputeKeyedStoreField(Handle<Name> name, |
Handle<JSObject> receiver, |
int field_index, |
Handle<Map> transition, |
@@ -559,7 +559,7 @@ Handle<Code> StubCache::ComputeKeyedStoreField(Handle<String> name, |
Handle<Code> StubCache::ComputeCallConstant(int argc, |
Code::Kind kind, |
Code::ExtraICState extra_state, |
- Handle<String> name, |
+ Handle<Name> name, |
Handle<Object> object, |
Handle<JSObject> holder, |
Handle<JSFunction> function) { |
@@ -603,7 +603,7 @@ Handle<Code> StubCache::ComputeCallConstant(int argc, |
Handle<Code> StubCache::ComputeCallField(int argc, |
Code::Kind kind, |
Code::ExtraICState extra_state, |
- Handle<String> name, |
+ Handle<Name> name, |
Handle<Object> object, |
Handle<JSObject> holder, |
PropertyIndex index) { |
@@ -643,7 +643,7 @@ Handle<Code> StubCache::ComputeCallField(int argc, |
Handle<Code> StubCache::ComputeCallInterceptor(int argc, |
Code::Kind kind, |
Code::ExtraICState extra_state, |
- Handle<String> name, |
+ Handle<Name> name, |
Handle<Object> object, |
Handle<JSObject> holder) { |
// Compute the check type and the map. |
@@ -682,7 +682,7 @@ Handle<Code> StubCache::ComputeCallInterceptor(int argc, |
Handle<Code> StubCache::ComputeCallGlobal(int argc, |
Code::Kind kind, |
Code::ExtraICState extra_state, |
- Handle<String> name, |
+ Handle<Name> name, |
Handle<JSObject> receiver, |
Handle<GlobalObject> holder, |
Handle<JSGlobalPropertyCell> cell, |
@@ -947,7 +947,7 @@ void StubCache::Clear() { |
void StubCache::CollectMatchingMaps(SmallMapList* types, |
- String* name, |
+ Name* name, |
Code::Flags flags, |
Handle<Context> native_context, |
Zone* zone) { |
@@ -1029,9 +1029,14 @@ RUNTIME_FUNCTION(MaybeObject*, StoreCallbackProperty) { |
v8::AccessorSetter fun = FUNCTION_CAST<v8::AccessorSetter>(setter_address); |
ASSERT(fun != NULL); |
ASSERT(callback->IsCompatibleReceiver(recv)); |
- Handle<String> name = args.at<String>(2); |
+ Handle<Name> name = args.at<Name>(2); |
Handle<Object> value = args.at<Object>(3); |
HandleScope scope(isolate); |
+ |
+ // TODO(rossberg): Support symbols in the API. |
+ if (name->IsSymbol()) return *value; |
+ Handle<String> str = Handle<String>::cast(name); |
+ |
LOG(isolate, ApiNamedPropertyAccess("store", recv, *name)); |
CustomArguments custom_args(isolate, callback->data(), recv, recv); |
v8::AccessorInfo info(custom_args.end()); |
@@ -1039,7 +1044,7 @@ RUNTIME_FUNCTION(MaybeObject*, StoreCallbackProperty) { |
// Leaving JavaScript. |
VMState state(isolate, EXTERNAL); |
ExternalCallbackScope call_scope(isolate, setter_address); |
- fun(v8::Utils::ToLocal(name), v8::Utils::ToLocal(value), info); |
+ fun(v8::Utils::ToLocal(str), v8::Utils::ToLocal(value), info); |
} |
RETURN_IF_SCHEDULED_EXCEPTION(isolate); |
return *value; |
@@ -1057,7 +1062,7 @@ static const int kAccessorInfoOffsetInInterceptorArgs = 2; |
* provide any value for the given name. |
*/ |
RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorOnly) { |
- Handle<String> name_handle = args.at<String>(0); |
+ Handle<Name> name_handle = args.at<Name>(0); |
Handle<InterceptorInfo> interceptor_info = args.at<InterceptorInfo>(1); |
ASSERT(kAccessorInfoOffsetInInterceptorArgs == 2); |
ASSERT(args[2]->IsJSObject()); // Receiver. |
@@ -1065,6 +1070,11 @@ RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorOnly) { |
ASSERT(args[5]->IsSmi()); // Isolate. |
ASSERT(args.length() == 6); |
+ // TODO(rossberg): Support symbols in the API. |
+ if (name_handle->IsSymbol()) |
+ return isolate->heap()->no_interceptor_result_sentinel(); |
+ Handle<String> name = Handle<String>::cast(name_handle); |
+ |
Address getter_address = v8::ToCData<Address>(interceptor_info->getter()); |
v8::NamedPropertyGetter getter = |
FUNCTION_CAST<v8::NamedPropertyGetter>(getter_address); |
@@ -1079,7 +1089,7 @@ RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorOnly) { |
{ |
// Leaving JavaScript. |
VMState state(isolate, EXTERNAL); |
- r = getter(v8::Utils::ToLocal(name_handle), info); |
+ r = getter(v8::Utils::ToLocal(name), info); |
} |
RETURN_IF_SCHEDULED_EXCEPTION(isolate); |
if (!r.IsEmpty()) { |
@@ -1093,7 +1103,7 @@ RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorOnly) { |
} |
-static MaybeObject* ThrowReferenceError(String* name) { |
+static MaybeObject* ThrowReferenceError(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, so we |
// can't use either LoadIC or KeyedLoadIC constructors. |
@@ -1103,7 +1113,7 @@ static MaybeObject* ThrowReferenceError(String* name) { |
// Throw a reference error. |
HandleScope scope; |
- Handle<String> name_handle(name); |
+ Handle<Name> name_handle(name); |
Handle<Object> error = |
FACTORY->NewReferenceError("not_defined", |
HandleVector(&name_handle, 1)); |
@@ -1113,7 +1123,7 @@ static MaybeObject* ThrowReferenceError(String* name) { |
static MaybeObject* LoadWithInterceptor(Arguments* args, |
PropertyAttributes* attrs) { |
- Handle<String> name_handle = args->at<String>(0); |
+ Handle<Name> name_handle = args->at<Name>(0); |
Handle<InterceptorInfo> interceptor_info = args->at<InterceptorInfo>(1); |
ASSERT(kAccessorInfoOffsetInInterceptorArgs == 2); |
Handle<JSObject> receiver_handle = args->at<JSObject>(2); |
@@ -1122,6 +1132,12 @@ static MaybeObject* LoadWithInterceptor(Arguments* args, |
Isolate* isolate = receiver_handle->GetIsolate(); |
+ // TODO(rossberg): Support symbols in the API. |
+ if (name_handle->IsSymbol()) |
+ return holder_handle->GetPropertyPostInterceptor( |
+ *receiver_handle, *name_handle, attrs); |
+ Handle<String> name = Handle<String>::cast(name_handle); |
+ |
Address getter_address = v8::ToCData<Address>(interceptor_info->getter()); |
v8::NamedPropertyGetter getter = |
FUNCTION_CAST<v8::NamedPropertyGetter>(getter_address); |
@@ -1136,7 +1152,7 @@ static MaybeObject* LoadWithInterceptor(Arguments* args, |
{ |
// Leaving JavaScript. |
VMState state(isolate, EXTERNAL); |
- r = getter(v8::Utils::ToLocal(name_handle), info); |
+ r = getter(v8::Utils::ToLocal(name), info); |
} |
RETURN_IF_SCHEDULED_EXCEPTION(isolate); |
if (!r.IsEmpty()) { |
@@ -1169,7 +1185,7 @@ RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorForLoad) { |
// If the property is present, return it. |
if (attr != ABSENT) return result; |
- return ThrowReferenceError(String::cast(args[0])); |
+ return ThrowReferenceError(Name::cast(args[0])); |
} |
@@ -1187,7 +1203,7 @@ RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorForCall) { |
RUNTIME_FUNCTION(MaybeObject*, StoreInterceptorProperty) { |
ASSERT(args.length() == 4); |
JSObject* recv = JSObject::cast(args[0]); |
- String* name = String::cast(args[1]); |
+ Name* name = Name::cast(args[1]); |
Object* value = args[2]; |
ASSERT(args.smi_at(3) == kStrictMode || args.smi_at(3) == kNonStrictMode); |
StrictModeFlag strict_mode = static_cast<StrictModeFlag>(args.smi_at(3)); |
@@ -1369,15 +1385,15 @@ Handle<Code> StubCompiler::GetCodeWithFlags(Code::Flags flags, |
Handle<Code> StubCompiler::GetCodeWithFlags(Code::Flags flags, |
- Handle<String> name) { |
- return (FLAG_print_code_stubs && !name.is_null()) |
- ? GetCodeWithFlags(flags, *name->ToCString()) |
+ Handle<Name> name) { |
+ return (FLAG_print_code_stubs && !name.is_null() && name->IsString()) |
+ ? GetCodeWithFlags(flags, *Handle<String>::cast(name)->ToCString()) |
: GetCodeWithFlags(flags, reinterpret_cast<char*>(NULL)); |
} |
void StubCompiler::LookupPostInterceptor(Handle<JSObject> holder, |
- Handle<String> name, |
+ Handle<Name> name, |
LookupResult* lookup) { |
holder->LocalLookupRealNamedProperty(*name, lookup); |
if (lookup->IsFound()) return; |
@@ -1391,7 +1407,7 @@ void StubCompiler::LookupPostInterceptor(Handle<JSObject> holder, |
Handle<Code> BaseLoadStubCompiler::CompileLoadField(Handle<JSObject> object, |
Handle<JSObject> holder, |
- Handle<String> name, |
+ Handle<Name> name, |
PropertyIndex index) { |
Label miss; |
@@ -1410,7 +1426,7 @@ Handle<Code> BaseLoadStubCompiler::CompileLoadField(Handle<JSObject> object, |
Handle<Code> BaseLoadStubCompiler::CompileLoadCallback( |
Handle<JSObject> object, |
Handle<JSObject> holder, |
- Handle<String> name, |
+ Handle<Name> name, |
Handle<AccessorInfo> callback) { |
Label miss; |
@@ -1429,7 +1445,7 @@ Handle<Code> BaseLoadStubCompiler::CompileLoadCallback( |
Handle<Code> BaseLoadStubCompiler::CompileLoadConstant( |
Handle<JSObject> object, |
Handle<JSObject> holder, |
- Handle<String> name, |
+ Handle<Name> name, |
Handle<JSFunction> value) { |
Label miss; |
@@ -1448,7 +1464,7 @@ Handle<Code> BaseLoadStubCompiler::CompileLoadConstant( |
Handle<Code> BaseLoadStubCompiler::CompileLoadInterceptor( |
Handle<JSObject> object, |
Handle<JSObject> holder, |
- Handle<String> name) { |
+ Handle<Name> name) { |
Label miss; |
LookupResult lookup(isolate()); |
@@ -1473,7 +1489,7 @@ Handle<Code> BaseLoadStubCompiler::CompileLoadInterceptor( |
Handle<Code> LoadStubCompiler::GetCode(Code::StubType type, |
- Handle<String> name, |
+ Handle<Name> name, |
InlineCacheState state) { |
Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, type); |
Handle<Code> code = GetCodeWithFlags(flags, name); |
@@ -1484,7 +1500,7 @@ Handle<Code> LoadStubCompiler::GetCode(Code::StubType type, |
Handle<Code> KeyedLoadStubCompiler::GetCode(Code::StubType type, |
- Handle<String> name, |
+ Handle<Name> name, |
InlineCacheState state) { |
Code::Flags flags = Code::ComputeFlags( |
Code::KEYED_LOAD_IC, state, Code::kNoExtraICState, type); |
@@ -1530,7 +1546,7 @@ Handle<Code> KeyedLoadStubCompiler::CompileLoadElementPolymorphic( |
Handle<Code> StoreStubCompiler::GetCode(Code::StubType type, |
- Handle<String> name) { |
+ Handle<Name> name) { |
Code::Flags flags = |
Code::ComputeMonomorphicFlags(Code::STORE_IC, type, strict_mode_); |
Handle<Code> code = GetCodeWithFlags(flags, name); |
@@ -1541,7 +1557,7 @@ Handle<Code> StoreStubCompiler::GetCode(Code::StubType type, |
Handle<Code> KeyedStoreStubCompiler::GetCode(Code::StubType type, |
- Handle<String> name, |
+ Handle<Name> name, |
InlineCacheState state) { |
Code::ExtraICState extra_state = |
Code::ComputeExtraICState(grow_mode_, strict_mode_); |
@@ -1663,7 +1679,7 @@ Handle<Code> CallStubCompiler::CompileCustomCall( |
Handle<Code> CallStubCompiler::GetCode(Code::StubType type, |
- Handle<String> name) { |
+ Handle<Name> name) { |
int argc = arguments_.immediate(); |
Code::Flags flags = Code::ComputeMonomorphicFlags(kind_, |
type, |