Revision: 24345
Author:   yang...@chromium.org
Date:     Wed Oct  1 07:08:39 2014 UTC
Log:      Use symbols instead of hidden properties for i18n markers.

Also refactor symbols in the root list.

R=dslo...@chromium.org

Review URL: https://codereview.chromium.org/614083002
https://code.google.com/p/v8/source/detail?r=24345

Deleted:
 /branches/bleeding_edge/test/mjsunit/test-hidden-string.js
Modified:
 /branches/bleeding_edge/include/v8.h
 /branches/bleeding_edge/src/factory.h
 /branches/bleeding_edge/src/heap/heap.cc
 /branches/bleeding_edge/src/heap/heap.h
 /branches/bleeding_edge/src/heap-snapshot-generator.cc
 /branches/bleeding_edge/src/hydrogen-instructions.cc
 /branches/bleeding_edge/src/runtime/runtime-i18n.cc
 /branches/bleeding_edge/src/runtime/runtime.cc
 /branches/bleeding_edge/src/runtime/runtime.h

=======================================
--- /branches/bleeding_edge/test/mjsunit/test-hidden-string.js Tue Mar 4 12:43:05 2014 UTC
+++ /dev/null
@@ -1,11 +0,0 @@
-// 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]);
=======================================
--- /branches/bleeding_edge/include/v8.h        Tue Sep 30 15:29:08 2014 UTC
+++ /branches/bleeding_edge/include/v8.h        Wed Oct  1 07:08:39 2014 UTC
@@ -5904,7 +5904,7 @@
   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.
=======================================
--- /branches/bleeding_edge/src/factory.h       Thu Sep 18 09:59:53 2014 UTC
+++ /branches/bleeding_edge/src/factory.h       Wed Oct  1 07:08:39 2014 UTC
@@ -588,6 +588,14 @@
   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);
   }
=======================================
--- /branches/bleeding_edge/src/heap/heap.cc    Tue Sep 30 15:29:08 2014 UTC
+++ /branches/bleeding_edge/src/heap/heap.cc    Wed Oct  1 07:08:39 2014 UTC
@@ -2868,20 +2868,10 @@
// 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);
=======================================
--- /branches/bleeding_edge/src/heap/heap.h     Tue Sep 30 15:29:08 2014 UTC
+++ /branches/bleeding_edge/src/heap/heap.h     Wed Oct  1 07:08:39 2014 UTC
@@ -175,22 +175,8 @@
V(JSObject, observation_state, ObservationState) \ V(Map, external_map, ExternalMap) \ V(Object, symbol_registry, SymbolRegistry) \ - V(Symbol, frozen_symbol, FrozenSymbol) \ - V(Symbol, nonexistent_symbol, NonExistentSymbol) \ - V(Symbol, elements_transition_symbol, ElementsTransitionSymbol) \ V(SeededNumberDictionary, empty_slow_element_dictionary, \ EmptySlowElementDictionary) \ - V(Symbol, observed_symbol, ObservedSymbol) \ - V(Symbol, uninitialized_symbol, UninitializedSymbol) \ - V(Symbol, megamorphic_symbol, MegamorphicSymbol) \ - V(Symbol, premonomorphic_symbol, PremonomorphicSymbol) \ - V(Symbol, generic_symbol, GenericSymbol) \ - V(Symbol, stack_trace_symbol, StackTraceSymbol) \ - V(Symbol, detailed_stack_trace_symbol, DetailedStackTraceSymbol) \ - V(Symbol, normal_ic_symbol, NormalICSymbol) \ - V(Symbol, home_object_symbol, HomeObjectSymbol) \ - V(Symbol, promise_debug_marker_symbol, PromiseDebugMarkerSymbol) \ - V(Symbol, promise_has_handler_symbol, PromiseHasHandlerSymbol) \ V(FixedArray, materialized_objects, MaterializedObjects) \ V(FixedArray, allocation_sites_scratchpad, AllocationSitesScratchpad) \
   V(FixedArray, microtask_queue, MicrotaskQueue)
@@ -261,83 +247,99 @@
   V(foreign_map)                        \
   V(neander_map)

-#define INTERNALIZED_STRING_LIST(V)                                \
-  V(Object_string, "Object")                                       \
-  V(proto_string, "__proto__")                                     \
-  V(arguments_string, "arguments")                                 \
-  V(Arguments_string, "Arguments")                                 \
-  V(caller_string, "caller")                                       \
-  V(boolean_string, "boolean")                                     \
-  V(Boolean_string, "Boolean")                                     \
-  V(callee_string, "callee")                                       \
-  V(constructor_string, "constructor")                             \
-  V(dot_result_string, ".result")                                  \
-  V(dot_for_string, ".for.")                                       \
-  V(eval_string, "eval")                                           \
-  V(empty_string, "")                                              \
-  V(function_string, "function")                                   \
-  V(Function_string, "Function")                                   \
-  V(length_string, "length")                                       \
-  V(name_string, "name")                                           \
-  V(null_string, "null")                                           \
-  V(number_string, "number")                                       \
-  V(Number_string, "Number")                                       \
-  V(nan_string, "NaN")                                             \
-  V(source_string, "source")                                       \
-  V(source_url_string, "source_url")                               \
-  V(source_mapping_url_string, "source_mapping_url")               \
-  V(global_string, "global")                                       \
-  V(ignore_case_string, "ignoreCase")                              \
-  V(multiline_string, "multiline")                                 \
-  V(sticky_string, "sticky")                                       \
-  V(harmony_regexps_string, "harmony_regexps")                     \
-  V(input_string, "input")                                         \
-  V(index_string, "index")                                         \
-  V(last_index_string, "lastIndex")                                \
-  V(object_string, "object")                                       \
-  V(prototype_string, "prototype")                                 \
-  V(string_string, "string")                                       \
-  V(String_string, "String")                                       \
-  V(symbol_string, "symbol")                                       \
-  V(Symbol_string, "Symbol")                                       \
-  V(Map_string, "Map")                                             \
-  V(Set_string, "Set")                                             \
-  V(WeakMap_string, "WeakMap")                                     \
-  V(WeakSet_string, "WeakSet")                                     \
-  V(for_string, "for")                                             \
-  V(for_api_string, "for_api")                                     \
-  V(for_intern_string, "for_intern")                               \
-  V(private_api_string, "private_api")                             \
-  V(private_intern_string, "private_intern")                       \
-  V(Date_string, "Date")                                           \
-  V(char_at_string, "CharAt")                                      \
-  V(undefined_string, "undefined")                                 \
-  V(value_of_string, "valueOf")                                    \
-  V(stack_string, "stack")                                         \
-  V(toJSON_string, "toJSON")                                       \
-  V(KeyedLoadMonomorphic_string, "KeyedLoadMonomorphic")           \
-  V(KeyedStoreMonomorphic_string, "KeyedStoreMonomorphic")         \
-  V(stack_overflow_string, "kStackOverflowBoilerplate")            \
-  V(illegal_access_string, "illegal access")                       \
-  V(cell_value_string, "%cell_value")                              \
-  V(illegal_argument_string, "illegal argument")                   \
-  V(identity_hash_string, "v8::IdentityHash")                      \
-  V(closure_string, "(closure)")                                   \
-  V(dot_string, ".")                                               \
-  V(compare_ic_string, "==")                                       \
-  V(strict_compare_ic_string, "===")                               \
-  V(infinity_string, "Infinity")                                   \
-  V(minus_infinity_string, "-Infinity")                            \
-  V(query_colon_string, "(?:)")                                    \
-  V(Generator_string, "Generator")                                 \
-  V(throw_string, "throw")                                         \
-  V(done_string, "done")                                           \
-  V(value_string, "value")                                         \
-  V(next_string, "next")                                           \
-  V(byte_length_string, "byteLength")                              \
-  V(byte_offset_string, "byteOffset")                              \
-  V(intl_initialized_marker_string, "v8::intl_initialized_marker") \
-  V(intl_impl_object_string, "v8::intl_object")
+#define INTERNALIZED_STRING_LIST(V)                        \
+  V(Object_string, "Object")                               \
+  V(proto_string, "__proto__")                             \
+  V(arguments_string, "arguments")                         \
+  V(Arguments_string, "Arguments")                         \
+  V(caller_string, "caller")                               \
+  V(boolean_string, "boolean")                             \
+  V(Boolean_string, "Boolean")                             \
+  V(callee_string, "callee")                               \
+  V(constructor_string, "constructor")                     \
+  V(dot_result_string, ".result")                          \
+  V(dot_for_string, ".for.")                               \
+  V(eval_string, "eval")                                   \
+  V(empty_string, "")                                      \
+  V(function_string, "function")                           \
+  V(Function_string, "Function")                           \
+  V(length_string, "length")                               \
+  V(name_string, "name")                                   \
+  V(null_string, "null")                                   \
+  V(number_string, "number")                               \
+  V(Number_string, "Number")                               \
+  V(nan_string, "NaN")                                     \
+  V(source_string, "source")                               \
+  V(source_url_string, "source_url")                       \
+  V(source_mapping_url_string, "source_mapping_url")       \
+  V(global_string, "global")                               \
+  V(ignore_case_string, "ignoreCase")                      \
+  V(multiline_string, "multiline")                         \
+  V(sticky_string, "sticky")                               \
+  V(harmony_regexps_string, "harmony_regexps")             \
+  V(input_string, "input")                                 \
+  V(index_string, "index")                                 \
+  V(last_index_string, "lastIndex")                        \
+  V(object_string, "object")                               \
+  V(prototype_string, "prototype")                         \
+  V(string_string, "string")                               \
+  V(String_string, "String")                               \
+  V(symbol_string, "symbol")                               \
+  V(Symbol_string, "Symbol")                               \
+  V(Map_string, "Map")                                     \
+  V(Set_string, "Set")                                     \
+  V(WeakMap_string, "WeakMap")                             \
+  V(WeakSet_string, "WeakSet")                             \
+  V(for_string, "for")                                     \
+  V(for_api_string, "for_api")                             \
+  V(for_intern_string, "for_intern")                       \
+  V(private_api_string, "private_api")                     \
+  V(private_intern_string, "private_intern")               \
+  V(Date_string, "Date")                                   \
+  V(char_at_string, "CharAt")                              \
+  V(undefined_string, "undefined")                         \
+  V(value_of_string, "valueOf")                            \
+  V(stack_string, "stack")                                 \
+  V(toJSON_string, "toJSON")                               \
+  V(KeyedLoadMonomorphic_string, "KeyedLoadMonomorphic")   \
+  V(KeyedStoreMonomorphic_string, "KeyedStoreMonomorphic") \
+  V(stack_overflow_string, "kStackOverflowBoilerplate")    \
+  V(illegal_access_string, "illegal access")               \
+  V(cell_value_string, "%cell_value")                      \
+  V(illegal_argument_string, "illegal argument")           \
+  V(identity_hash_string, "v8::IdentityHash")              \
+  V(closure_string, "(closure)")                           \
+  V(dot_string, ".")                                       \
+  V(compare_ic_string, "==")                               \
+  V(strict_compare_ic_string, "===")                       \
+  V(infinity_string, "Infinity")                           \
+  V(minus_infinity_string, "-Infinity")                    \
+  V(query_colon_string, "(?:)")                            \
+  V(Generator_string, "Generator")                         \
+  V(throw_string, "throw")                                 \
+  V(done_string, "done")                                   \
+  V(value_string, "value")                                 \
+  V(next_string, "next")                                   \
+  V(byte_length_string, "byteLength")                      \
+  V(byte_offset_string, "byteOffset")
+
+#define PRIVATE_SYMBOL_LIST(V)      \
+  V(frozen_symbol)                  \
+  V(nonexistent_symbol)             \
+  V(elements_transition_symbol)     \
+  V(observed_symbol)                \
+  V(uninitialized_symbol)           \
+  V(megamorphic_symbol)             \
+  V(premonomorphic_symbol)          \
+  V(generic_symbol)                 \
+  V(stack_trace_symbol)             \
+  V(detailed_stack_trace_symbol)    \
+  V(normal_ic_symbol)               \
+  V(home_object_symbol)             \
+  V(intl_initialized_marker_symbol) \
+  V(intl_impl_object_symbol)        \
+  V(promise_debug_marker_symbol)    \
+  V(promise_has_handler_symbol)

 // Forward declarations.
 class HeapStats;
@@ -785,6 +787,11 @@
   INTERNALIZED_STRING_LIST(STRING_ACCESSOR)
 #undef STRING_ACCESSOR

+#define SYMBOL_ACCESSOR(name) \
+  Symbol* name() { return Symbol::cast(roots_[k##name##RootIndex]); }
+  PRIVATE_SYMBOL_LIST(SYMBOL_ACCESSOR)
+#undef SYMBOL_ACCESSOR
+
   // The hidden_string is special because it is the empty string, but does
   // not match the empty string.
   String* hidden_string() { return hidden_string_; }
@@ -1062,6 +1069,10 @@
     INTERNALIZED_STRING_LIST(STRING_INDEX_DECLARATION)
 #undef STRING_DECLARATION

+#define SYMBOL_INDEX_DECLARATION(name) k##name##RootIndex,
+    PRIVATE_SYMBOL_LIST(SYMBOL_INDEX_DECLARATION)
+#undef SYMBOL_INDEX_DECLARATION
+
 // Utility type maps
 #define DECLARE_STRUCT_MAP(NAME, Name, name) k##Name##MapRootIndex,
     STRUCT_LIST(DECLARE_STRUCT_MAP)
=======================================
--- /branches/bleeding_edge/src/heap-snapshot-generator.cc Mon Sep 22 14:40:59 2014 UTC +++ /branches/bleeding_edge/src/heap-snapshot-generator.cc Wed Oct 1 07:08:39 2014 UTC
@@ -2164,6 +2164,9 @@
 #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());
   }
=======================================
--- /branches/bleeding_edge/src/hydrogen-instructions.cc Tue Sep 30 10:29:32 2014 UTC +++ /branches/bleeding_edge/src/hydrogen-instructions.cc Wed Oct 1 07:08:39 2014 UTC
@@ -2873,6 +2873,9 @@
       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;
 }

=======================================
--- /branches/bleeding_edge/src/runtime/runtime-i18n.cc Thu Sep 25 07:16:15 2014 UTC +++ /branches/bleeding_edge/src/runtime/runtime-i18n.cc Wed Oct 1 07:08:39 2014 UTC
@@ -233,9 +233,9 @@
   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 @@
   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 @@
   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 @@

   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,
=======================================
--- /branches/bleeding_edge/src/runtime/runtime.cc Tue Sep 30 15:29:08 2014 UTC +++ /branches/bleeding_edge/src/runtime/runtime.cc Wed Oct 1 07:08:39 2014 UTC
@@ -1038,18 +1038,6 @@
   if (name->IsString()) name = String::Flatten(Handle<String>::cast(name));
   return JSReceiver::DeleteProperty(receiver, name, mode);
 }
-
-
-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) {
=======================================
--- /branches/bleeding_edge/src/runtime/runtime.h Tue Sep 30 15:29:08 2014 UTC +++ /branches/bleeding_edge/src/runtime/runtime.h Wed Oct 1 07:08:39 2014 UTC
@@ -256,7 +256,6 @@
   F(DefineDataPropertyUnchecked, 4, 1)                 \
   F(DefineAccessorPropertyUnchecked, 5, 1)             \
   F(GetDataProperty, 2, 1)                             \
-  F(SetHiddenProperty, 3, 1)                           \
                                                        \
   /* Arrays */                                         \
   F(RemoveArrayHoles, 2, 1)                            \

--
--
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to