Commit 153ec032 authored by yangguo@chromium.org's avatar yangguo@chromium.org

Use symbols instead of hidden properties for i18n markers.

Also refactor symbols in the root list.

R=dslomov@chromium.org

Review URL: https://codereview.chromium.org/614083002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24345 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 356d668d
......@@ -5904,7 +5904,7 @@ class Internals {
static const int kNullValueRootIndex = 7;
static const int kTrueValueRootIndex = 8;
static const int kFalseValueRootIndex = 9;
static const int kEmptyStringRootIndex = 166;
static const int kEmptyStringRootIndex = 152;
// The external allocation limit should be below 256 MB on all architectures
// to avoid that resource-constrained embedders run low on memory.
......
......@@ -588,6 +588,14 @@ class Factory FINAL {
INTERNALIZED_STRING_LIST(STRING_ACCESSOR)
#undef STRING_ACCESSOR
#define SYMBOL_ACCESSOR(name) \
inline Handle<Symbol> name() { \
return Handle<Symbol>(bit_cast<Symbol**>( \
&isolate()->heap()->roots_[Heap::k##name##RootIndex])); \
}
PRIVATE_SYMBOL_LIST(SYMBOL_ACCESSOR)
#undef SYMBOL_ACCESSOR
inline void set_string_table(Handle<StringTable> table) {
isolate()->heap()->set_string_table(*table);
}
......
......@@ -2164,6 +2164,9 @@ const char* V8HeapExplorer::GetStrongGcSubrootName(Object* object) {
#define STRING_NAME(name, str) NAME_ENTRY(name)
INTERNALIZED_STRING_LIST(STRING_NAME)
#undef STRING_NAME
#define SYMBOL_NAME(name) NAME_ENTRY(name)
PRIVATE_SYMBOL_LIST(SYMBOL_NAME)
#undef SYMBOL_NAME
#undef NAME_ENTRY
CHECK(!strong_gc_subroot_names_.is_empty());
}
......
......@@ -2868,20 +2868,10 @@ void Heap::CreateInitialObjects() {
// Number of queued microtasks stored in Isolate::pending_microtask_count().
set_microtask_queue(empty_fixed_array());
set_detailed_stack_trace_symbol(*factory->NewPrivateOwnSymbol());
set_elements_transition_symbol(*factory->NewPrivateOwnSymbol());
set_frozen_symbol(*factory->NewPrivateOwnSymbol());
set_megamorphic_symbol(*factory->NewPrivateOwnSymbol());
set_premonomorphic_symbol(*factory->NewPrivateOwnSymbol());
set_generic_symbol(*factory->NewPrivateOwnSymbol());
set_nonexistent_symbol(*factory->NewPrivateOwnSymbol());
set_normal_ic_symbol(*factory->NewPrivateOwnSymbol());
set_observed_symbol(*factory->NewPrivateOwnSymbol());
set_stack_trace_symbol(*factory->NewPrivateOwnSymbol());
set_uninitialized_symbol(*factory->NewPrivateOwnSymbol());
set_home_object_symbol(*factory->NewPrivateOwnSymbol());
set_promise_debug_marker_symbol(*factory->NewPrivateOwnSymbol());
set_promise_has_handler_symbol(*factory->NewPrivateOwnSymbol());
#define SYMBOL_INIT(name) \
roots_[k##name##RootIndex] = *factory->NewPrivateOwnSymbol();
PRIVATE_SYMBOL_LIST(SYMBOL_INIT)
#undef SYMBOL_INIT
Handle<SeededNumberDictionary> slow_element_dictionary =
SeededNumberDictionary::New(isolate(), 0, TENURED);
......
This diff is collapsed.
......@@ -2873,6 +2873,9 @@ bool HConstant::ImmortalImmovable() const {
object_.IsKnownGlobal(heap->name##_map()) ||
STRING_TYPE_LIST(STRING_TYPE)
#undef STRING_TYPE
#define SYMBOL(name) object_.IsKnownGlobal(heap->name()) ||
PRIVATE_SYMBOL_LIST(SYMBOL)
#undef SYMBOL
false;
}
......
......@@ -233,9 +233,9 @@ RUNTIME_FUNCTION(Runtime_IsInitializedIntlObject) {
if (!input->IsJSObject()) return isolate->heap()->false_value();
Handle<JSObject> obj = Handle<JSObject>::cast(input);
Handle<String> marker = isolate->factory()->intl_initialized_marker_string();
Handle<Object> tag(obj->GetHiddenProperty(marker), isolate);
return isolate->heap()->ToBoolean(!tag->IsTheHole());
Handle<Symbol> marker = isolate->factory()->intl_initialized_marker_symbol();
Handle<Object> tag = JSObject::GetDataProperty(obj, marker);
return isolate->heap()->ToBoolean(!tag->IsUndefined());
}
......@@ -250,8 +250,8 @@ RUNTIME_FUNCTION(Runtime_IsInitializedIntlObjectOfType) {
if (!input->IsJSObject()) return isolate->heap()->false_value();
Handle<JSObject> obj = Handle<JSObject>::cast(input);
Handle<String> marker = isolate->factory()->intl_initialized_marker_string();
Handle<Object> tag(obj->GetHiddenProperty(marker), isolate);
Handle<Symbol> marker = isolate->factory()->intl_initialized_marker_symbol();
Handle<Object> tag = JSObject::GetDataProperty(obj, marker);
return isolate->heap()->ToBoolean(tag->IsString() &&
String::cast(*tag)->Equals(*expected_type));
}
......@@ -266,11 +266,11 @@ RUNTIME_FUNCTION(Runtime_MarkAsInitializedIntlObjectOfType) {
CONVERT_ARG_HANDLE_CHECKED(String, type, 1);
CONVERT_ARG_HANDLE_CHECKED(JSObject, impl, 2);
Handle<String> marker = isolate->factory()->intl_initialized_marker_string();
JSObject::SetHiddenProperty(input, marker, type);
Handle<Symbol> marker = isolate->factory()->intl_initialized_marker_symbol();
JSObject::SetProperty(input, marker, type, STRICT).Assert();
marker = isolate->factory()->intl_impl_object_string();
JSObject::SetHiddenProperty(input, marker, impl);
marker = isolate->factory()->intl_impl_object_symbol();
JSObject::SetProperty(input, marker, impl, STRICT).Assert();
return isolate->heap()->undefined_value();
}
......@@ -291,8 +291,9 @@ RUNTIME_FUNCTION(Runtime_GetImplFromInitializedIntlObject) {
Handle<JSObject> obj = Handle<JSObject>::cast(input);
Handle<String> marker = isolate->factory()->intl_impl_object_string();
Handle<Object> impl(obj->GetHiddenProperty(marker), isolate);
Handle<Symbol> marker = isolate->factory()->intl_impl_object_symbol();
Handle<Object> impl = JSObject::GetDataProperty(obj, marker);
if (impl->IsTheHole()) {
Vector<Handle<Object> > arguments = HandleVector(&obj, 1);
THROW_NEW_ERROR_RETURN_FAILURE(isolate,
......
......@@ -1040,18 +1040,6 @@ MaybeHandle<Object> Runtime::DeleteObjectProperty(Isolate* isolate,
}
RUNTIME_FUNCTION(Runtime_SetHiddenProperty) {
HandleScope scope(isolate);
RUNTIME_ASSERT(args.length() == 3);
CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
CONVERT_ARG_HANDLE_CHECKED(String, key, 1);
CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
RUNTIME_ASSERT(key->IsUniqueName());
return *JSObject::SetHiddenProperty(object, key, value);
}
RUNTIME_FUNCTION(Runtime_AddNamedProperty) {
HandleScope scope(isolate);
RUNTIME_ASSERT(args.length() == 4);
......
......@@ -256,7 +256,6 @@ namespace internal {
F(DefineDataPropertyUnchecked, 4, 1) \
F(DefineAccessorPropertyUnchecked, 5, 1) \
F(GetDataProperty, 2, 1) \
F(SetHiddenProperty, 3, 1) \
\
/* Arrays */ \
F(RemoveArrayHoles, 2, 1) \
......
// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --allow-natives-syntax
var o = {};
%SetHiddenProperty(o, "test", 1);
// Create non-internalized ""
var empty = "a".substring(1, 1);
assertEquals(undefined, o[empty]);
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