Native context: do not put public symbols and flags on the js builtins object.
authoryangguo <yangguo@chromium.org>
Fri, 28 Aug 2015 10:22:31 +0000 (03:22 -0700)
committerCommit bot <commit-bot@chromium.org>
Fri, 28 Aug 2015 10:22:41 +0000 (10:22 +0000)
R=cbruni@chromium.org,mlippautz@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#30438}

39 files changed:
src/array-iterator.js
src/array.js
src/arraybuffer.js
src/bootstrapper.cc
src/bootstrapper.h
src/collection-iterator.js
src/collection.js
src/date.js
src/debug/mirrors.js
src/factory.h
src/generator.js
src/harmony-array.js
src/harmony-atomics.js
src/harmony-concat-spreadable.js
src/harmony-reflect.js
src/harmony-sharedarraybuffer.js
src/harmony-simd.js
src/harmony-tostring.js
src/heap-snapshot-generator.cc
src/heap/heap-inl.h
src/heap/heap.cc
src/heap/heap.h
src/i18n.js
src/iterator-prototype.js
src/json.js
src/math.js
src/messages.js
src/prologue.js
src/promise.js
src/regexp.js
src/runtime.js
src/runtime/runtime-internal.cc
src/runtime/runtime.h
src/string-iterator.js
src/string.js
src/symbol.js
src/typedarray.js
src/v8natives.js
src/weak-collection.js

index 67f1eef..e59bfd7 100644 (file)
@@ -14,12 +14,14 @@ var $arrayValues;
 // Imports
 
 var arrayIterationKindSymbol =
-    utils.GetPrivateSymbol("array_iteration_kind_symbol");
+    utils.ImportNow("array_iteration_kind_symbol");
 var arrayIteratorNextIndexSymbol =
-    utils.GetPrivateSymbol("array_iterator_next_symbol");
+    utils.ImportNow("array_iterator_next_symbol");
 var arrayIteratorObjectSymbol =
-    utils.GetPrivateSymbol("array_iterator_object_symbol");
+    utils.ImportNow("array_iterator_object_symbol");
 var GlobalArray = global.Array;
+var iteratorSymbol = utils.ImportNow("iterator_symbol");
+var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
 
 macro TYPED_ARRAYS(FUNCTION)
   FUNCTION(Uint8Array)
@@ -132,10 +134,10 @@ function ArrayKeys() {
 utils.InstallFunctions(ArrayIterator.prototype, DONT_ENUM, [
   'next', ArrayIteratorNext
 ]);
-utils.SetFunctionName(ArrayIteratorIterator, symbolIterator);
-%AddNamedProperty(ArrayIterator.prototype, symbolIterator,
+utils.SetFunctionName(ArrayIteratorIterator, iteratorSymbol);
+%AddNamedProperty(ArrayIterator.prototype, iteratorSymbol,
                   ArrayIteratorIterator, DONT_ENUM);
-%AddNamedProperty(ArrayIterator.prototype, symbolToStringTag,
+%AddNamedProperty(ArrayIterator.prototype, toStringTagSymbol,
                   "Array Iterator", READ_ONLY | DONT_ENUM);
 
 utils.InstallFunctions(GlobalArray.prototype, DONT_ENUM, [
@@ -148,14 +150,14 @@ utils.InstallFunctions(GlobalArray.prototype, DONT_ENUM, [
 // InstallFunctions block, as it'll be redundant.
 utils.SetFunctionName(ArrayValues, 'values');
 
-%AddNamedProperty(GlobalArray.prototype, symbolIterator, ArrayValues,
+%AddNamedProperty(GlobalArray.prototype, iteratorSymbol, ArrayValues,
                   DONT_ENUM);
 
 macro EXTEND_TYPED_ARRAY(NAME)
   %AddNamedProperty(GlobalNAME.prototype, 'entries', ArrayEntries, DONT_ENUM);
   %AddNamedProperty(GlobalNAME.prototype, 'values', ArrayValues, DONT_ENUM);
   %AddNamedProperty(GlobalNAME.prototype, 'keys', ArrayKeys, DONT_ENUM);
-  %AddNamedProperty(GlobalNAME.prototype, symbolIterator, ArrayValues,
+  %AddNamedProperty(GlobalNAME.prototype, iteratorSymbol, ArrayValues,
                     DONT_ENUM);
 endmacro
 
index af3dbd7..84c7662 100644 (file)
@@ -22,6 +22,7 @@ var ObjectIsSealed;
 var ObjectToString;
 var ToNumber;
 var ToString;
+var unscopablesSymbol = utils.ImportNow("unscopables_symbol");
 
 utils.Import(function(from) {
   Delete = from.Delete;
@@ -1610,7 +1611,7 @@ var unscopables = {
   keys: true,
 };
 
-%AddNamedProperty(GlobalArray.prototype, symbolUnscopables, unscopables,
+%AddNamedProperty(GlobalArray.prototype, unscopablesSymbol, unscopables,
                   DONT_ENUM | READ_ONLY);
 
 // Set up non-enumerable functions on the Array object.
index 2edcd12..0db0c2b 100644 (file)
@@ -16,6 +16,7 @@ var GlobalObject = global.Object;
 var MathMax;
 var MathMin;
 var ToNumber;
+var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
 
 utils.Import(function(from) {
   MathMax = from.MathMax;
@@ -93,9 +94,10 @@ function ArrayBufferIsViewJS(obj) {
     GlobalArrayBuffer.prototype, "constructor", GlobalArrayBuffer, DONT_ENUM);
 
 %AddNamedProperty(GlobalArrayBuffer.prototype,
-    symbolToStringTag, "ArrayBuffer", DONT_ENUM | READ_ONLY);
+    toStringTagSymbol, "ArrayBuffer", DONT_ENUM | READ_ONLY);
 
-utils.InstallGetter(GlobalArrayBuffer.prototype, "byteLength", ArrayBufferGetByteLen);
+utils.InstallGetter(GlobalArrayBuffer.prototype, "byteLength",
+                    ArrayBufferGetByteLen);
 
 utils.InstallFunctions(GlobalArrayBuffer, DONT_ENUM, [
   "isView", ArrayBufferIsViewJS
index 9d2121e..93f9151 100644 (file)
@@ -1756,18 +1756,58 @@ void Genesis::InitializeBuiltinTypedArrays() {
 }
 
 
-void Bootstrapper::ExportPrivateSymbols(Isolate* isolate,
-                                        Handle<JSObject> container) {
+void Bootstrapper::ExportFromRuntime(Isolate* isolate,
+                                     Handle<JSObject> container) {
   HandleScope scope(isolate);
 #define EXPORT_PRIVATE_SYMBOL(NAME)                                         \
   Handle<String> NAME##_name =                                              \
       isolate->factory()->NewStringFromAsciiChecked(#NAME);                 \
   JSObject::AddProperty(container, NAME##_name, isolate->factory()->NAME(), \
                         NONE);
-
   PRIVATE_SYMBOL_LIST(EXPORT_PRIVATE_SYMBOL)
-
 #undef EXPORT_PRIVATE_SYMBOL
+
+#define EXPORT_PUBLIC_SYMBOL(NAME, DESCRIPTION)                             \
+  Handle<String> NAME##_name =                                              \
+      isolate->factory()->NewStringFromAsciiChecked(#NAME);                 \
+  JSObject::AddProperty(container, NAME##_name, isolate->factory()->NAME(), \
+                        NONE);
+  PUBLIC_SYMBOL_LIST(EXPORT_PUBLIC_SYMBOL)
+#undef EXPORT_PUBLIC_SYMBOL
+
+  Handle<JSFunction> apply = InstallFunction(
+      container, "reflect_apply", JS_OBJECT_TYPE, JSObject::kHeaderSize,
+      MaybeHandle<JSObject>(), Builtins::kReflectApply);
+  apply->shared()->set_internal_formal_parameter_count(3);
+  apply->shared()->set_length(3);
+  isolate->native_context()->set_reflect_apply(*apply);
+
+  Handle<JSFunction> construct = InstallFunction(
+      container, "reflect_construct", JS_OBJECT_TYPE, JSObject::kHeaderSize,
+      MaybeHandle<JSObject>(), Builtins::kReflectConstruct);
+  construct->shared()->set_internal_formal_parameter_count(3);
+  construct->shared()->set_length(2);
+  isolate->native_context()->set_reflect_construct(*construct);
+}
+
+
+void Bootstrapper::ExportExperimentalFromRuntime(Isolate* isolate,
+                                                 Handle<JSObject> container) {
+  HandleScope scope(isolate);
+
+#define INITIALIZE_FLAG(FLAG)                                         \
+  {                                                                   \
+    Handle<String> name =                                             \
+        isolate->factory()->NewStringFromAsciiChecked(#FLAG);         \
+    JSObject::AddProperty(container, name,                            \
+                          isolate->factory()->ToBoolean(FLAG), NONE); \
+  }
+
+  INITIALIZE_FLAG(FLAG_harmony_regexps)
+  INITIALIZE_FLAG(FLAG_harmony_unicode_regexps)
+  INITIALIZE_FLAG(FLAG_harmony_tostring)
+
+#undef INITIALIZE_FLAG
 }
 
 
@@ -1791,48 +1831,12 @@ EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_spread_arrays)
 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_atomics)
 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_new_target)
 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_concat_spreadable)
-
-void Genesis::InitializeGlobal_harmony_regexps() {
-  Handle<JSObject> builtins(native_context()->builtins());
-
-  Handle<HeapObject> flag(FLAG_harmony_regexps ? heap()->true_value()
-                                               : heap()->false_value());
-  Runtime::SetObjectProperty(isolate(), builtins,
-                             factory()->harmony_regexps_string(), flag,
-                             STRICT).Assert();
-}
-
-
-void Genesis::InitializeGlobal_harmony_unicode_regexps() {
-  Handle<JSObject> builtins(native_context()->builtins());
-
-  Handle<HeapObject> flag(FLAG_harmony_unicode_regexps ? heap()->true_value()
-                                                       : heap()->false_value());
-  Runtime::SetObjectProperty(isolate(), builtins,
-                             factory()->harmony_unicode_regexps_string(), flag,
-                             STRICT).Assert();
-}
+EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexps)
+EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_unicode_regexps)
+EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_tostring)
 
 
 void Genesis::InitializeGlobal_harmony_reflect() {
-  Handle<JSObject> builtins(native_context()->builtins());
-
-  Handle<JSFunction> apply = InstallFunction(
-      builtins, "$reflectApply", JS_OBJECT_TYPE, JSObject::kHeaderSize,
-      MaybeHandle<JSObject>(), Builtins::kReflectApply);
-  apply->shared()->set_internal_formal_parameter_count(3);
-  apply->shared()->set_length(3);
-
-  native_context()->set_reflect_apply(*apply);
-
-  Handle<JSFunction> construct = InstallFunction(
-      builtins, "$reflectConstruct", JS_OBJECT_TYPE, JSObject::kHeaderSize,
-      MaybeHandle<JSObject>(), Builtins::kReflectConstruct);
-  construct->shared()->set_internal_formal_parameter_count(3);
-  construct->shared()->set_length(2);
-
-  native_context()->set_reflect_construct(*construct);
-
   if (!FLAG_harmony_reflect) return;
 
   Handle<JSGlobalObject> global(JSGlobalObject::cast(
@@ -1845,16 +1849,6 @@ void Genesis::InitializeGlobal_harmony_reflect() {
 }
 
 
-void Genesis::InitializeGlobal_harmony_tostring() {
-  Handle<JSObject> builtins(native_context()->builtins());
-
-  Handle<HeapObject> flag(FLAG_harmony_tostring ? heap()->true_value()
-                                                : heap()->false_value());
-  Runtime::SetObjectProperty(isolate(), builtins,
-                             factory()->harmony_tostring_string(), flag,
-                             STRICT).Assert();
-}
-
 
 void Genesis::InitializeGlobal_harmony_sharedarraybuffer() {
   if (!FLAG_harmony_sharedarraybuffer) return;
@@ -2277,17 +2271,6 @@ bool Genesis::InstallNatives(ContextType context_type) {
     return true;
   }
 
-  // Install public symbols.
-  {
-    static const PropertyAttributes attributes =
-        static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE);
-#define INSTALL_PUBLIC_SYMBOL(name, varname, description)                 \
-  Handle<String> varname = factory()->NewStringFromStaticChars(#varname); \
-  JSObject::AddProperty(builtins, varname, factory()->name(), attributes);
-    PUBLIC_SYMBOL_LIST(INSTALL_PUBLIC_SYMBOL)
-#undef INSTALL_PUBLIC_SYMBOL
-  }
-
   // Run the rest of the native scripts.
   while (builtin_index < Natives::GetBuiltinsCount()) {
     if (!Bootstrapper::CompileBuiltin(isolate(), builtin_index++)) return false;
index 0e1d0c9..b69a73a 100644 (file)
@@ -119,8 +119,9 @@ class Bootstrapper final {
   static bool CompileCodeStubBuiltin(Isolate* isolate, int index);
   static bool InstallCodeStubNatives(Isolate* isolate);
 
-  static void ExportPrivateSymbols(Isolate* isolate,
-                                   Handle<JSObject> container);
+  static void ExportFromRuntime(Isolate* isolate, Handle<JSObject> container);
+  static void ExportExperimentalFromRuntime(Isolate* isolate,
+                                            Handle<JSObject> container);
 
  private:
   Isolate* isolate_;
index 8cae606..9cfe31e 100644 (file)
@@ -15,6 +15,8 @@ var $setValues;
 
 var GlobalMap = global.Map;
 var GlobalSet = global.Set;
+var iteratorSymbol = utils.ImportNow("iterator_symbol");
+var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
 
 // -------------------------------------------------------------------
 
@@ -74,7 +76,7 @@ utils.InstallFunctions(SetIterator.prototype, DONT_ENUM, [
   'next', SetIteratorNextJS
 ]);
 
-%AddNamedProperty(SetIterator.prototype, symbolToStringTag,
+%AddNamedProperty(SetIterator.prototype, toStringTagSymbol,
     "Set Iterator", READ_ONLY | DONT_ENUM);
 
 utils.InstallFunctions(GlobalSet.prototype, DONT_ENUM, [
@@ -83,7 +85,7 @@ utils.InstallFunctions(GlobalSet.prototype, DONT_ENUM, [
   'values', SetValues
 ]);
 
-%AddNamedProperty(GlobalSet.prototype, symbolIterator, SetValues, DONT_ENUM);
+%AddNamedProperty(GlobalSet.prototype, iteratorSymbol, SetValues, DONT_ENUM);
 
 $setIteratorNext = SetIteratorNextJS;
 $setValues = SetValues;
@@ -156,7 +158,7 @@ utils.InstallFunctions(MapIterator.prototype, DONT_ENUM, [
   'next', MapIteratorNextJS
 ]);
 
-%AddNamedProperty(MapIterator.prototype, symbolToStringTag,
+%AddNamedProperty(MapIterator.prototype, toStringTagSymbol,
     "Map Iterator", READ_ONLY | DONT_ENUM);
 
 
@@ -166,7 +168,7 @@ utils.InstallFunctions(GlobalMap.prototype, DONT_ENUM, [
   'values', MapValues
 ]);
 
-%AddNamedProperty(GlobalMap.prototype, symbolIterator, MapEntries, DONT_ENUM);
+%AddNamedProperty(GlobalMap.prototype, iteratorSymbol, MapEntries, DONT_ENUM);
 
 $mapEntries = MapEntries;
 $mapIteratorNext = MapIteratorNextJS;
index 718ca9b..ad4ad1e 100644 (file)
@@ -16,8 +16,9 @@ var $getExistingHash;
 var GlobalMap = global.Map;
 var GlobalObject = global.Object;
 var GlobalSet = global.Set;
-var hashCodeSymbol = utils.GetPrivateSymbol("hash_code_symbol");
+var hashCodeSymbol = utils.ImportNow("hash_code_symbol");
 var IntRandom;
+var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
 
 utils.Import(function(from) {
   IntRandom = from.IntRandom;
@@ -270,7 +271,7 @@ function SetForEach(f, receiver) {
 %FunctionSetLength(GlobalSet, 0);
 %FunctionSetPrototype(GlobalSet, new GlobalObject());
 %AddNamedProperty(GlobalSet.prototype, "constructor", GlobalSet, DONT_ENUM);
-%AddNamedProperty(GlobalSet.prototype, symbolToStringTag, "Set",
+%AddNamedProperty(GlobalSet.prototype, toStringTagSymbol, "Set",
                   DONT_ENUM | READ_ONLY);
 
 %FunctionSetLength(SetForEach, 1);
@@ -460,7 +461,7 @@ function MapForEach(f, receiver) {
 %FunctionSetPrototype(GlobalMap, new GlobalObject());
 %AddNamedProperty(GlobalMap.prototype, "constructor", GlobalMap, DONT_ENUM);
 %AddNamedProperty(
-    GlobalMap.prototype, symbolToStringTag, "Map", DONT_ENUM | READ_ONLY);
+    GlobalMap.prototype, toStringTagSymbol, "Map", DONT_ENUM | READ_ONLY);
 
 %FunctionSetLength(MapForEach, 1);
 
index 44d2f4d..5df3afa 100644 (file)
@@ -21,6 +21,7 @@ var IsFinite;
 var MathAbs;
 var MathFloor;
 var ToNumber;
+var toPrimitiveSymbol = utils.ImportNow("to_primitive_symbol");
 var ToString;
 
 utils.Import(function(from) {
@@ -847,8 +848,8 @@ utils.InstallFunctions(GlobalDate, DONT_ENUM, [
 
 // Set up non-enumerable constructor property of the Date prototype object.
 %AddNamedProperty(GlobalDate.prototype, "constructor", GlobalDate, DONT_ENUM);
-utils.SetFunctionName(DateToPrimitive, symbolToPrimitive);
-%AddNamedProperty(GlobalDate.prototype, symbolToPrimitive, DateToPrimitive,
+utils.SetFunctionName(DateToPrimitive, toPrimitiveSymbol);
+%AddNamedProperty(GlobalDate.prototype, toPrimitiveSymbol, DateToPrimitive,
                   DONT_ENUM | READ_ONLY);
 
 // Set up non-enumerable functions of the Date prototype object and
index 43f0e02..e77f7a0 100644 (file)
@@ -13,13 +13,15 @@ var GlobalArray = global.Array;
 var IsNaN = global.isNaN;
 var JSONStringify = global.JSON.stringify;
 var MathMin = global.Math.min;
-var promiseStatusSymbol = utils.GetPrivateSymbol("promise_status_symbol");
-var promiseValueSymbol = utils.GetPrivateSymbol("promise_value_symbol");
+var promiseStatusSymbol = utils.ImportNow("promise_status_symbol");
+var promiseValueSymbol = utils.ImportNow("promise_value_symbol");
+var SymbolToString;
 var ToBoolean;
 var ToString;
 
 utils.Import(function(from) {
   FunctionSourceString = from.FunctionSourceString;
+  SymbolToString = from.SymbolToString;
   ToBoolean = from.ToBoolean;
   ToString = from.ToString;
 });
@@ -694,7 +696,7 @@ SymbolMirror.prototype.description = function() {
 
 
 SymbolMirror.prototype.toText = function() {
-  return %_CallFunction(this.value_, builtins.$symbolToString);
+  return %_CallFunction(this.value_, SymbolToString);
 }
 
 
index e93bd36..6e8f950 100644 (file)
@@ -615,7 +615,7 @@ class Factory final {
   PRIVATE_SYMBOL_LIST(SYMBOL_ACCESSOR)
 #undef SYMBOL_ACCESSOR
 
-#define SYMBOL_ACCESSOR(name, varname, description)             \
+#define SYMBOL_ACCESSOR(name, description)                      \
   inline Handle<Symbol> name() {                                \
     return Handle<Symbol>(bit_cast<Symbol**>(                   \
         &isolate()->heap()->roots_[Heap::k##name##RootIndex])); \
index d041c5b..56579c5 100644 (file)
@@ -12,8 +12,8 @@
 // Imports
 
 var GlobalFunction = global.Function;
-
 var NewFunctionString;
+var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
 
 utils.Import(function(from) {
   NewFunctionString = from.NewFunctionString;
@@ -102,10 +102,10 @@ utils.InstallFunctions(GeneratorObjectPrototype,
 %AddNamedProperty(GeneratorObjectPrototype, "constructor",
     GeneratorFunctionPrototype, DONT_ENUM | READ_ONLY);
 %AddNamedProperty(GeneratorObjectPrototype,
-    symbolToStringTag, "Generator", DONT_ENUM | READ_ONLY);
+    toStringTagSymbol, "Generator", DONT_ENUM | READ_ONLY);
 %InternalSetPrototype(GeneratorFunctionPrototype, GlobalFunction.prototype);
 %AddNamedProperty(GeneratorFunctionPrototype,
-    symbolToStringTag, "GeneratorFunction", DONT_ENUM | READ_ONLY);
+    toStringTagSymbol, "GeneratorFunction", DONT_ENUM | READ_ONLY);
 %AddNamedProperty(GeneratorFunctionPrototype, "constructor",
     GeneratorFunction, DONT_ENUM | READ_ONLY);
 %InternalSetPrototype(GeneratorFunction, GlobalFunction);
index 4917646..885950b 100644 (file)
@@ -14,7 +14,7 @@
 var GetIterator;
 var GetMethod;
 var GlobalArray = global.Array;
-var GlobalSymbol = global.Symbol;
+var iteratorSymbol = utils.ImportNow("iterator_symbol");
 var MathMax;
 var MathMin;
 var ObjectIsFrozen;
@@ -221,7 +221,7 @@ function ArrayFrom(arrayLike, mapfn, receiver) {
     }
   }
 
-  var iterable = GetMethod(items, symbolIterator);
+  var iterable = GetMethod(items, iteratorSymbol);
   var k;
   var result;
   var mappedValue;
index d4e0696..fae9420 100644 (file)
@@ -14,6 +14,7 @@
 var GlobalObject = global.Object;
 var MathMax;
 var ToNumber;
+var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
 
 utils.Import(function(from) {
   MathMax = from.MathMax;
@@ -192,7 +193,7 @@ var Atomics = new AtomicsConstructor();
 %AddNamedProperty(global, "Atomics", Atomics, DONT_ENUM);
 %FunctionSetInstanceClassName(AtomicsConstructor, 'Atomics');
 
-%AddNamedProperty(Atomics, symbolToStringTag, "Atomics", READ_ONLY | DONT_ENUM);
+%AddNamedProperty(Atomics, toStringTagSymbol, "Atomics", READ_ONLY | DONT_ENUM);
 
 // These must match the values in src/futex-emulation.h
 utils.InstallConstants(Atomics, [
index 362701c..c5d906a 100644 (file)
@@ -8,9 +8,12 @@
 
 %CheckIsBootstrapping();
 
+var isConcatSpreadableSymbol =
+    utils.ImportNow("is_concat_spreadable_symbol");
+
 utils.InstallConstants(global.Symbol, [
   // TODO(littledan): Move to symbol.js when shipping
-  "isConcatSpreadable", symbolIsConcatSpreadable
+  "isConcatSpreadable", isConcatSpreadableSymbol
 ]);
 
 })
index 1e6a7d2..f1fe860 100644 (file)
@@ -2,9 +2,6 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-// TODO(yangguo): Remove this file. Do all of this in
-//                Genesis::InitializeGlobal_harmony_reflect
-
 (function(global, utils) {
 
 'use strict';
 %CheckIsBootstrapping();
 
 var GlobalReflect = global.Reflect;
+var ReflectApply = utils.ImportNow("reflect_apply");
+var ReflectConstruct = utils.ImportNow("reflect_construct");
 
 utils.InstallFunctions(GlobalReflect, DONT_ENUM, [
-  "apply", $reflectApply,
-  "construct", $reflectConstruct
+  "apply", ReflectApply,
+  "construct", ReflectConstruct
 ]);
 
 })
index 4ebfaad..3a72d6c 100644 (file)
@@ -10,6 +10,7 @@
 
 var GlobalSharedArrayBuffer = global.SharedArrayBuffer;
 var GlobalObject = global.Object;
+var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
 
 // -------------------------------------------------------------------
 
@@ -44,7 +45,7 @@ function SharedArrayBufferIsViewJS(obj) {
                   GlobalSharedArrayBuffer, DONT_ENUM);
 
 %AddNamedProperty(GlobalSharedArrayBuffer.prototype,
-    symbolToStringTag, "SharedArrayBuffer", DONT_ENUM | READ_ONLY);
+    toStringTagSymbol, "SharedArrayBuffer", DONT_ENUM | READ_ONLY);
 
 utils.InstallGetter(GlobalSharedArrayBuffer.prototype, "byteLength",
                     SharedArrayBufferGetByteLen);
index 9f8d916..84ff063 100644 (file)
@@ -12,6 +12,7 @@
 // Imports
 
 var GlobalSIMD = global.SIMD;
+var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
 
 macro SIMD_FLOAT_TYPES(FUNCTION)
 FUNCTION(Float32x4, float32x4, 4)
@@ -577,14 +578,14 @@ function Float32x4MaxNumJS(a, b) {
 }
 
 
-%AddNamedProperty(GlobalSIMD, symbolToStringTag, 'SIMD', READ_ONLY | DONT_ENUM);
+%AddNamedProperty(GlobalSIMD, toStringTagSymbol, 'SIMD', READ_ONLY | DONT_ENUM);
 
 macro SETUP_SIMD_TYPE(NAME, TYPE, LANES)
 %SetCode(GlobalNAME, NAMEConstructor);
 %FunctionSetPrototype(GlobalNAME, {});
 %AddNamedProperty(GlobalNAME.prototype, 'constructor', GlobalNAME,
     DONT_ENUM);
-%AddNamedProperty(GlobalNAME.prototype, symbolToStringTag, 'NAME',
+%AddNamedProperty(GlobalNAME.prototype, toStringTagSymbol, 'NAME',
     DONT_ENUM | READ_ONLY);
 utils.InstallFunctions(GlobalNAME.prototype, DONT_ENUM, [
   'toLocaleString', NAMEToLocaleString,
index e234781..8e76c3a 100644 (file)
@@ -9,10 +9,11 @@
 %CheckIsBootstrapping();
 
 var GlobalSymbol = global.Symbol;
+var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
 
 utils.InstallConstants(GlobalSymbol, [
    // TODO(dslomov, caitp): Move to symbol.js when shipping
-   "toStringTag", symbolToStringTag
+   "toStringTag", toStringTagSymbol
 ]);
 
 })
index 8dddf2c..3fda04f 100644 (file)
@@ -2162,7 +2162,7 @@ const char* V8HeapExplorer::GetStrongGcSubrootName(Object* object) {
 #define SYMBOL_NAME(name) NAME_ENTRY(name)
     PRIVATE_SYMBOL_LIST(SYMBOL_NAME)
 #undef SYMBOL_NAME
-#define SYMBOL_NAME(name, varname, description) NAME_ENTRY(name)
+#define SYMBOL_NAME(name, description) NAME_ENTRY(name)
     PUBLIC_SYMBOL_LIST(SYMBOL_NAME)
 #undef SYMBOL_NAME
 #undef NAME_ENTRY
index a3785d0..e5e4981 100644 (file)
@@ -66,7 +66,7 @@ INTERNALIZED_STRING_LIST(STRING_ACCESSOR)
 PRIVATE_SYMBOL_LIST(SYMBOL_ACCESSOR)
 #undef SYMBOL_ACCESSOR
 
-#define SYMBOL_ACCESSOR(name, varname, description) \
+#define SYMBOL_ACCESSOR(name, description) \
   Symbol* Heap::name() { return Symbol::cast(roots_[k##name##RootIndex]); }
 PUBLIC_SYMBOL_LIST(SYMBOL_ACCESSOR)
 #undef SYMBOL_ACCESSOR
index 151a8ed..ab52719 100644 (file)
@@ -3220,7 +3220,7 @@ void Heap::CreateInitialObjects() {
 
   {
     HandleScope scope(isolate());
-#define SYMBOL_INIT(name, varname, description)                             \
+#define SYMBOL_INIT(name, description)                                      \
   Handle<Symbol> name = factory->NewSymbol();                               \
   Handle<String> name##d = factory->NewStringFromStaticChars(#description); \
   name->set_name(*name##d);                                                 \
index 826933d..a4ecdf7 100644 (file)
@@ -258,9 +258,6 @@ namespace internal {
   V(multiline_string, "multiline")                             \
   V(sticky_string, "sticky")                                   \
   V(unicode_string, "unicode")                                 \
-  V(harmony_regexps_string, "harmony_regexps")                 \
-  V(harmony_tostring_string, "harmony_tostring")               \
-  V(harmony_unicode_regexps_string, "harmony_unicode_regexps") \
   V(input_string, "input")                                     \
   V(index_string, "index")                                     \
   V(last_index_string, "lastIndex")                            \
@@ -348,16 +345,14 @@ namespace internal {
   V(string_iterator_next_index_symbol)      \
   V(uninitialized_symbol)
 
-
-#define PUBLIC_SYMBOL_LIST(V)                                    \
-  V(has_instance_symbol, symbolHasInstance, Symbol.hasInstance)  \
-  V(is_concat_spreadable_symbol, symbolIsConcatSpreadable,       \
-    Symbol.isConcatSpreadable)                                   \
-  V(is_regexp_symbol, symbolIsRegExp, Symbol.isRegExp)           \
-  V(iterator_symbol, symbolIterator, Symbol.iterator)            \
-  V(to_primitive_symbol, symbolToPrimitive, Symbol.toPrimitive)  \
-  V(to_string_tag_symbol, symbolToStringTag, Symbol.toStringTag) \
-  V(unscopables_symbol, symbolUnscopables, Symbol.unscopables)
+#define PUBLIC_SYMBOL_LIST(V)                               \
+  V(has_instance_symbol, Symbol.hasInstance)                \
+  V(is_concat_spreadable_symbol, Symbol.isConcatSpreadable) \
+  V(is_regexp_symbol, Symbol.isRegExp)                      \
+  V(iterator_symbol, Symbol.iterator)                       \
+  V(to_primitive_symbol, Symbol.toPrimitive)                \
+  V(to_string_tag_symbol, Symbol.toStringTag)               \
+  V(unscopables_symbol, Symbol.unscopables)
 
 // Heap roots that are known to be immortal immovable, for which we can safely
 // skip write barriers. This list is not complete and has omissions.
@@ -563,7 +558,7 @@ class Heap {
             PRIVATE_SYMBOL_LIST(SYMBOL_INDEX_DECLARATION)
 #undef SYMBOL_INDEX_DECLARATION
 
-#define SYMBOL_INDEX_DECLARATION(name, varname, description) k##name##RootIndex,
+#define SYMBOL_INDEX_DECLARATION(name, description) k##name##RootIndex,
                 PUBLIC_SYMBOL_LIST(SYMBOL_INDEX_DECLARATION)
 #undef SYMBOL_INDEX_DECLARATION
 
@@ -1198,7 +1193,7 @@ class Heap {
   PRIVATE_SYMBOL_LIST(SYMBOL_ACCESSOR)
 #undef SYMBOL_ACCESSOR
 
-#define SYMBOL_ACCESSOR(name, varname, description) inline Symbol* name();
+#define SYMBOL_ACCESSOR(name, description) inline Symbol* name();
   PUBLIC_SYMBOL_LIST(SYMBOL_ACCESSOR)
 #undef SYMBOL_ACCESSOR
 
index f0bcbc3..c50f1f9 100644 (file)
@@ -28,6 +28,8 @@ var GlobalNumber = global.Number;
 var GlobalRegExp = global.RegExp;
 var GlobalString = global.String;
 var MathFloor;
+var ObjectDefineProperties = utils.ImportNow("ObjectDefineProperties");
+var ObjectDefineProperty = utils.ImportNow("ObjectDefineProperty");
 var RegExpTest;
 var StringIndexOf;
 var StringLastIndexOf;
@@ -55,11 +57,6 @@ utils.Import(function(from) {
   ToNumber = from.ToNumber;
 });
 
-utils.ImportNow(function(from) {
-  ObjectDefineProperties = from.ObjectDefineProperties;
-  ObjectDefineProperty = from.ObjectDefineProperty;
-});
-
 // -------------------------------------------------------------------
 
 var Intl = {};
index 96dd7bf..2f49d90 100644 (file)
@@ -9,13 +9,14 @@ var $iteratorPrototype;
   %CheckIsBootstrapping();
 
   var GlobalObject = global.Object;
+  var iteratorSymbol = utils.ImportNow("iterator_symbol");
 
   // 25.1.2.1 %IteratorPrototype% [ @@iterator ] ( )
   function IteratorPrototypeIterator() {
     return this;
   }
 
-  utils.SetFunctionName(IteratorPrototypeIterator, symbolIterator);
-  %AddNamedProperty($iteratorPrototype, symbolIterator,
+  utils.SetFunctionName(IteratorPrototypeIterator, iteratorSymbol);
+  %AddNamedProperty($iteratorPrototype, iteratorSymbol,
       IteratorPrototypeIterator, DONT_ENUM);
 })
index 8d046ee..7ada63e 100644 (file)
@@ -18,6 +18,7 @@ var MathMin;
 var ObjectHasOwnProperty;
 var ToNumber;
 var ToString;
+var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
 
 utils.Import(function(from) {
   MathMax = from.MathMax;
@@ -234,7 +235,7 @@ function JSONStringify(value, replacer, space) {
 
 // -------------------------------------------------------------------
 
-%AddNamedProperty(GlobalJSON, symbolToStringTag, "JSON", READ_ONLY | DONT_ENUM);
+%AddNamedProperty(GlobalJSON, toStringTagSymbol, "JSON", READ_ONLY | DONT_ENUM);
 
 // Set up non-enumerable properties of the JSON object.
 utils.InstallFunctions(GlobalJSON, DONT_ENUM, [
index 51f4d44..05eb9e4 100644 (file)
@@ -15,6 +15,7 @@ var rngstate;  // Initialized to a Uint32Array during genesis.
 var GlobalMath = global.Math;
 var GlobalObject = global.Object;
 var InternalArray = utils.InternalArray;
+var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
 
 //-------------------------------------------------------------------
 
@@ -288,7 +289,7 @@ function CubeRoot(x) {
 
 // -------------------------------------------------------------------
 
-%AddNamedProperty(GlobalMath, symbolToStringTag, "Math", READ_ONLY | DONT_ENUM);
+%AddNamedProperty(GlobalMath, toStringTagSymbol, "Math", READ_ONLY | DONT_ENUM);
 
 // Set up math constants.
 utils.InstallConstants(GlobalMath, [
index b930a38..2e73d6e 100644 (file)
@@ -25,29 +25,31 @@ var Bool16x8ToString;
 var Bool32x4ToString;
 var Bool8x16ToString;
 var callSiteReceiverSymbol =
-    utils.GetPrivateSymbol("call_site_receiver_symbol");
+    utils.ImportNow("call_site_receiver_symbol");
 var callSiteFunctionSymbol =
-    utils.GetPrivateSymbol("call_site_function_symbol");
+    utils.ImportNow("call_site_function_symbol");
 var callSitePositionSymbol =
-    utils.GetPrivateSymbol("call_site_position_symbol");
-var callSiteStrictSymbol = utils.GetPrivateSymbol("call_site_strict_symbol");
+    utils.ImportNow("call_site_position_symbol");
+var callSiteStrictSymbol =
+    utils.ImportNow("call_site_strict_symbol");
 var Float32x4ToString;
 var formattedStackTraceSymbol =
-    utils.GetPrivateSymbol("formatted_stack_trace_symbol");
+    utils.ImportNow("formatted_stack_trace_symbol");
 var FunctionSourceString
 var GlobalObject = global.Object;
 var Int16x8ToString;
 var Int32x4ToString;
 var Int8x16ToString;
 var InternalArray = utils.InternalArray;
-var internalErrorSymbol = utils.GetPrivateSymbol("internal_error_symbol");
+var internalErrorSymbol = utils.ImportNow("internal_error_symbol");
 var ObjectDefineProperty;
 var ObjectToString;
-var stackTraceSymbol = utils.GetPrivateSymbol("stack_trace_symbol");
+var stackTraceSymbol = utils.ImportNow("stack_trace_symbol");
 var StringCharAt;
 var StringIndexOf;
 var StringSubstring;
-var ToString;
+var SymbolToString;
+var ToString = utils.ImportNow("ToString");
 var Uint16x8ToString;
 var Uint32x4ToString;
 var Uint8x16ToString;
@@ -67,15 +69,12 @@ utils.Import(function(from) {
   StringCharAt = from.StringCharAt;
   StringIndexOf = from.StringIndexOf;
   StringSubstring = from.StringSubstring;
+  SymbolToString = from.SymbolToString;
   Uint16x8ToString = from.Uint16x8ToString;
   Uint32x4ToString = from.Uint32x4ToString;
   Uint8x16ToString = from.Uint8x16ToString;
 });
 
-utils.ImportNow(function(from) {
-  ToString = from.ToString;
-});
-
 // -------------------------------------------------------------------
 
 var GlobalError;
@@ -108,7 +107,7 @@ function NoSideEffectToString(obj) {
     }
     return str;
   }
-  if (IS_SYMBOL(obj)) return %_CallFunction(obj, $symbolToString);
+  if (IS_SYMBOL(obj)) return %_CallFunction(obj, SymbolToString);
   if (IS_SIMD_VALUE(obj)) {
     switch (typeof(obj)) {
       case 'float32x4': return %_CallFunction(obj, Float32x4ToString);
index 5a0832c..5defb53 100644 (file)
@@ -13,7 +13,7 @@
 
 var imports = UNDEFINED;
 var imports_from_experimental = UNDEFINED;
-var exports_container = {};
+var exports_container = %ExportFromRuntime({});
 
 // Export to other scripts.
 // In normal natives, this exports functions to other normal natives.
@@ -36,11 +36,12 @@ function Import(f) {
   imports = f;
 }
 
+
 // Import immediately from exports of previous scripts. We need this for
 // functions called during bootstrapping. Hooking up imports in PostNatives
 // would be too late.
-function ImportNow(f) {
-  f(exports_container);
+function ImportNow(name) {
+  return exports_container[name];
 }
 
 
@@ -149,12 +150,6 @@ function SetUpLockedPrototype(
 }
 
 
-var private_symbols = %ExportPrivateSymbols({});
-
-function GetPrivateSymbol(name) {
-  return private_symbols[name];
-}
-
 // -----------------------------------------------------------------------
 // To be called by bootstrapper
 
@@ -190,10 +185,19 @@ function PostNatives(utils) {
     "ObjectIsFrozen",
     "ObjectDefineProperty",
     "OwnPropertyKeys",
+    "SymbolToString",
     "ToNameArray",
     "ToBoolean",
     "ToNumber",
     "ToString",
+    // From runtime:
+    "is_concat_spreadable_symbol",
+    "iterator_symbol",
+    "promise_status_symbol",
+    "promise_value_symbol",
+    "reflect_apply",
+    "reflect_construct",
+    "to_string_tag_symbol",
   ];
 
   var filtered_exports = {};
@@ -212,7 +216,7 @@ function PostNatives(utils) {
 
 function PostExperimentals(utils) {
   %CheckIsBootstrapping();
-
+  %ExportExperimentalFromRuntime(exports_container);
   for ( ; !IS_UNDEFINED(imports); imports = imports.next) {
     imports(exports_container);
   }
@@ -222,7 +226,6 @@ function PostExperimentals(utils) {
   }
 
   exports_container = UNDEFINED;
-  private_symbols = UNDEFINED;
 
   utils.PostExperimentals = UNDEFINED;
   utils.PostDebug = UNDEFINED;
@@ -237,7 +240,6 @@ function PostDebug(utils) {
   }
 
   exports_container = UNDEFINED;
-  private_symbols = UNDEFINED;
 
   utils.PostDebug = UNDEFINED;
   utils.PostExperimentals = UNDEFINED;
@@ -247,13 +249,12 @@ function PostDebug(utils) {
 
 // -----------------------------------------------------------------------
 
-%OptimizeObjectForAddingMultipleProperties(utils, 14);
+%OptimizeObjectForAddingMultipleProperties(utils, 13);
 
 utils.Import = Import;
 utils.ImportNow = ImportNow;
 utils.Export = Export;
 utils.ImportFromExperimental = ImportFromExperimental;
-utils.GetPrivateSymbol = GetPrivateSymbol;
 utils.SetFunctionName = SetFunctionName;
 utils.InstallConstants = InstallConstants;
 utils.InstallFunctions = InstallFunctions;
index db1f360..0872195 100644 (file)
 
 var InternalArray = utils.InternalArray;
 var promiseHasHandlerSymbol =
-    utils.GetPrivateSymbol("promise_has_handler_symbol");
-var promiseOnRejectSymbol = utils.GetPrivateSymbol("promise_on_reject_symbol");
+    utils.ImportNow("promise_has_handler_symbol");
+var promiseOnRejectSymbol = utils.ImportNow("promise_on_reject_symbol");
 var promiseOnResolveSymbol =
-    utils.GetPrivateSymbol("promise_on_resolve_symbol");
-var promiseRawSymbol = utils.GetPrivateSymbol("promise_raw_symbol");
-var promiseStatusSymbol = utils.GetPrivateSymbol("promise_status_symbol");
-var promiseValueSymbol = utils.GetPrivateSymbol("promise_value_symbol");
+    utils.ImportNow("promise_on_resolve_symbol");
+var promiseRawSymbol = utils.ImportNow("promise_raw_symbol");
+var promiseStatusSymbol = utils.ImportNow("promise_status_symbol");
+var promiseValueSymbol = utils.ImportNow("promise_value_symbol");
+var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
 
 // -------------------------------------------------------------------
 
@@ -361,7 +362,7 @@ function PromiseHasUserDefinedRejectHandler() {
 // Install exported functions.
 
 %AddNamedProperty(global, 'Promise', GlobalPromise, DONT_ENUM);
-%AddNamedProperty(GlobalPromise.prototype, symbolToStringTag, "Promise",
+%AddNamedProperty(GlobalPromise.prototype, toStringTagSymbol, "Promise",
                   DONT_ENUM | READ_ONLY);
 
 utils.InstallFunctions(GlobalPromise, DONT_ENUM, [
index a6a543f..3e5c0b6 100644 (file)
@@ -3,8 +3,6 @@
 // found in the LICENSE file.
 
 var $regexpLastMatchInfoOverride;
-var harmony_regexps = false;
-var harmony_unicode_regexps = false;
 
 (function(global, utils) {
 
@@ -13,6 +11,8 @@ var harmony_unicode_regexps = false;
 // -------------------------------------------------------------------
 // Imports
 
+var FLAG_harmony_regexps;
+var FLAG_harmony_unicode_regexps;
 var GlobalRegExp = global.RegExp;
 var InternalPackedArray = utils.InternalPackedArray;
 var ToNumber;
@@ -21,6 +21,11 @@ utils.Import(function(from) {
   ToNumber = from.ToNumber;
 });
 
+utils.ImportFromExperimental(function(from) {
+  FLAG_harmony_regexps = from.FLAG_harmony_regexps;
+  FLAG_harmony_unicode_regexps = from.FLAG_harmony_unicode_regexps;
+});
+
 // -------------------------------------------------------------------
 
 // Property of the builtins object for recording the result of the last
@@ -54,9 +59,9 @@ function DoConstructRegExp(object, pattern, flags) {
     flags = (pattern.global ? 'g' : '')
         + (pattern.ignoreCase ? 'i' : '')
         + (pattern.multiline ? 'm' : '');
-    if (harmony_unicode_regexps)
+    if (FLAG_harmony_unicode_regexps)
         flags += (pattern.unicode ? 'u' : '');
-    if (harmony_regexps)
+    if (FLAG_harmony_regexps)
         flags += (pattern.sticky ? 'y' : '');
     pattern = pattern.source;
   }
@@ -163,7 +168,7 @@ function RegExpExecJS(string) {
   // algorithm, step 5) even if the value is discarded for non-global RegExps.
   var i = TO_INTEGER(lastIndex);
 
-  var updateLastIndex = this.global || (harmony_regexps && this.sticky);
+  var updateLastIndex = this.global || (FLAG_harmony_regexps && this.sticky);
   if (updateLastIndex) {
     if (i < 0 || i > string.length) {
       this.lastIndex = 0;
@@ -211,7 +216,7 @@ function RegExpTest(string) {
   // algorithm, step 5) even if the value is discarded for non-global RegExps.
   var i = TO_INTEGER(lastIndex);
 
-  if (this.global || (harmony_regexps && this.sticky)) {
+  if (this.global || (FLAG_harmony_regexps && this.sticky)) {
     if (i < 0 || i > string.length) {
       this.lastIndex = 0;
       return false;
@@ -269,8 +274,8 @@ function RegExpToString() {
   if (this.global) result += 'g';
   if (this.ignoreCase) result += 'i';
   if (this.multiline) result += 'm';
-  if (harmony_unicode_regexps && this.unicode) result += 'u';
-  if (harmony_regexps && this.sticky) result += 'y';
+  if (FLAG_harmony_unicode_regexps && this.unicode) result += 'u';
+  if (FLAG_harmony_regexps && this.sticky) result += 'y';
   return result;
 }
 
index 72871e6..1c4faf2 100644 (file)
@@ -32,6 +32,8 @@ var GlobalArray = global.Array;
 var GlobalBoolean = global.Boolean;
 var GlobalString = global.String;
 var GlobalNumber = global.Number;
+var isConcatSpreadableSymbol =
+    utils.ImportNow("is_concat_spreadable_symbol");
 
 // ----------------------------------------------------------------------------
 
@@ -752,7 +754,7 @@ function IsPrimitive(x) {
 // ES6, draft 10-14-14, section 22.1.3.1.1
 function IsConcatSpreadable(O) {
   if (!IS_SPEC_OBJECT(O)) return false;
-  var spreadable = O[symbolIsConcatSpreadable];
+  var spreadable = O[isConcatSpreadableSymbol];
   if (IS_UNDEFINED(spreadable)) return IS_ARRAY(O);
   return ToBoolean(spreadable);
 }
index 582ce53..d5d57a0 100644 (file)
@@ -24,15 +24,28 @@ RUNTIME_FUNCTION(Runtime_CheckIsBootstrapping) {
 }
 
 
-RUNTIME_FUNCTION(Runtime_ExportPrivateSymbols) {
+RUNTIME_FUNCTION(Runtime_ExportFromRuntime) {
   HandleScope scope(isolate);
   DCHECK(args.length() == 1);
   CONVERT_ARG_HANDLE_CHECKED(JSObject, container, 0);
   RUNTIME_ASSERT(isolate->bootstrapper()->IsActive());
   JSObject::NormalizeProperties(container, KEEP_INOBJECT_PROPERTIES, 10,
-                                "ExportPrivateSymbols");
-  Bootstrapper::ExportPrivateSymbols(isolate, container);
-  JSObject::MigrateSlowToFast(container, 0, "ExportPrivateSymbols");
+                                "ExportFromRuntime");
+  Bootstrapper::ExportFromRuntime(isolate, container);
+  JSObject::MigrateSlowToFast(container, 0, "ExportFromRuntime");
+  return *container;
+}
+
+
+RUNTIME_FUNCTION(Runtime_ExportExperimentalFromRuntime) {
+  HandleScope scope(isolate);
+  DCHECK(args.length() == 1);
+  CONVERT_ARG_HANDLE_CHECKED(JSObject, container, 0);
+  RUNTIME_ASSERT(isolate->bootstrapper()->IsActive());
+  JSObject::NormalizeProperties(container, KEEP_INOBJECT_PROPERTIES, 10,
+                                "ExportExperimentalFromRuntime");
+  Bootstrapper::ExportExperimentalFromRuntime(isolate, container);
+  JSObject::MigrateSlowToFast(container, 0, "ExportExperimentalFromRuntime");
   return *container;
 }
 
index b3d9283..26f0308 100644 (file)
@@ -302,7 +302,8 @@ namespace internal {
 
 #define FOR_EACH_INTRINSIC_INTERNAL(F)        \
   F(CheckIsBootstrapping, 0, 1)               \
-  F(ExportPrivateSymbols, 1, 1)               \
+  F(ExportFromRuntime, 1, 1)                  \
+  F(ExportExperimentalFromRuntime, 1, 1)      \
   F(InstallToContext, 1, 1)                   \
   F(Throw, 1, 1)                              \
   F(ReThrow, 1, 1)                            \
index 4e51a12..c55d967 100644 (file)
 
 var ArrayIteratorCreateResultObject;
 var GlobalString = global.String;
+var iteratorSymbol = utils.ImportNow("iterator_symbol");
 var stringIteratorIteratedStringSymbol =
-    utils.GetPrivateSymbol("string_iterator_iterated_string_symbol");
+    utils.ImportNow("string_iterator_iterated_string_symbol");
 var stringIteratorNextIndexSymbol =
-    utils.GetPrivateSymbol("string_iterator_next_index_symbol");
+    utils.ImportNow("string_iterator_next_index_symbol");
+var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
 
 utils.Import(function(from) {
   ArrayIteratorCreateResultObject = from.ArrayIteratorCreateResultObject;
@@ -91,11 +93,11 @@ function StringPrototypeIterator() {
 utils.InstallFunctions(StringIterator.prototype, DONT_ENUM, [
   'next', StringIteratorNext
 ]);
-%AddNamedProperty(StringIterator.prototype, symbolToStringTag,
+%AddNamedProperty(StringIterator.prototype, toStringTagSymbol,
                   "String Iterator", READ_ONLY | DONT_ENUM);
 
-utils.SetFunctionName(StringPrototypeIterator, symbolIterator);
-%AddNamedProperty(GlobalString.prototype, symbolIterator,
+utils.SetFunctionName(StringPrototypeIterator, iteratorSymbol);
+%AddNamedProperty(GlobalString.prototype, iteratorSymbol,
                   StringPrototypeIterator, DONT_ENUM);
 
 })
index 8e7fc6c..0812958 100644 (file)
@@ -20,6 +20,7 @@ var MathMin;
 var RegExpExec;
 var RegExpExecNoTests;
 var RegExpLastMatchInfo;
+var SymbolToString;
 var ToNumber;
 var ToString;
 
@@ -31,6 +32,7 @@ utils.Import(function(from) {
   RegExpExec = from.RegExpExec;
   RegExpExecNoTests = from.RegExpExecNoTests;
   RegExpLastMatchInfo = from.RegExpLastMatchInfo;
+  SymbolToString = from.SymbolToString;
   ToNumber = from.ToNumber;
   ToString = from.ToString;
 });
@@ -43,7 +45,7 @@ function StringConstructor(x) {
     %_SetValueOf(this, TO_STRING_INLINE(x));
   } else {
     return IS_SYMBOL(x) ?
-        %_CallFunction(x, $symbolToString) : TO_STRING_INLINE(x);
+        %_CallFunction(x, SymbolToString) : TO_STRING_INLINE(x);
   }
 }
 
index 3f6e281..84386a9 100644 (file)
@@ -2,17 +2,6 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-// Expects following symbols to be set in the bootstrapper during genesis:
-// - symbolHasInstance
-// - symbolIsConcatSpreadable
-// - symbolIsRegExp
-// - symbolIterator
-// - symbolToPrimitive
-// - symbolToStringTag
-// - symbolUnscopables
-
-var $symbolToString;
-
 (function(global, utils) {
 
 "use strict";
@@ -24,8 +13,16 @@ var $symbolToString;
 
 var GlobalObject = global.Object;
 var GlobalSymbol = global.Symbol;
+var hasInstanceSymbol = utils.ImportNow("has_instance_symbol");
+var isConcatSpreadableSymbol =
+    utils.ImportNow("is_concat_spreadable_symbol");
+var isRegExpSymbol = utils.ImportNow("is_regexp_symbol");
+var iteratorSymbol = utils.ImportNow("iterator_symbol");
 var ObjectGetOwnPropertyKeys;
+var toPrimitiveSymbol = utils.ImportNow("to_primitive_symbol");
 var ToString;
+var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
+var unscopablesSymbol = utils.ImportNow("unscopables_symbol");
 
 utils.Import(function(from) {
   ObjectGetOwnPropertyKeys = from.ObjectGetOwnPropertyKeys;
@@ -97,22 +94,22 @@ function ObjectGetOwnPropertySymbols(obj) {
   return ObjectGetOwnPropertyKeys(obj, PROPERTY_ATTRIBUTES_STRING);
 }
 
-//-------------------------------------------------------------------
+// -------------------------------------------------------------------
 
 %SetCode(GlobalSymbol, SymbolConstructor);
 %FunctionSetPrototype(GlobalSymbol, new GlobalObject());
 
 utils.InstallConstants(GlobalSymbol, [
   // TODO(rossberg): expose when implemented.
-  // "hasInstance", symbolHasInstance,
-  // "isConcatSpreadable", symbolIsConcatSpreadable,
-  // "isRegExp", symbolIsRegExp,
-  "iterator", symbolIterator,
-  "toPrimitive", symbolToPrimitive,
+  // "hasInstance", hasInstanceSymbol,
+  // "isConcatSpreadable", isConcatSpreadableSymbol,
+  // "isRegExp", isRegExpSymbol,
+  "iterator", iteratorSymbol,
+  "toPrimitive", toPrimitiveSymbol,
   // TODO(dslomov, caitp): Currently defined in harmony-tostring.js ---
   // Move here when shipping
-  // "toStringTag", symbolToStringTag,
-  "unscopables", symbolUnscopables
+  // "toStringTag", toStringTagSymbol,
+  "unscopables", unscopablesSymbol,
 ]);
 
 utils.InstallFunctions(GlobalSymbol, DONT_ENUM, [
@@ -122,12 +119,12 @@ utils.InstallFunctions(GlobalSymbol, DONT_ENUM, [
 
 %AddNamedProperty(
     GlobalSymbol.prototype, "constructor", GlobalSymbol, DONT_ENUM);
-utils.SetFunctionName(SymbolToPrimitive, symbolToPrimitive);
+utils.SetFunctionName(SymbolToPrimitive, toPrimitiveSymbol);
 %AddNamedProperty(
-    GlobalSymbol.prototype, symbolToPrimitive, SymbolToPrimitive,
+    GlobalSymbol.prototype, toPrimitiveSymbol, SymbolToPrimitive,
     DONT_ENUM | READ_ONLY);
 %AddNamedProperty(
-    GlobalSymbol.prototype, symbolToStringTag, "Symbol", DONT_ENUM | READ_ONLY);
+    GlobalSymbol.prototype, toStringTagSymbol, "Symbol", DONT_ENUM | READ_ONLY);
 
 utils.InstallFunctions(GlobalSymbol.prototype, DONT_ENUM, [
   "toString", SymbolToString,
@@ -138,6 +135,11 @@ utils.InstallFunctions(GlobalObject, DONT_ENUM, [
   "getOwnPropertySymbols", ObjectGetOwnPropertySymbols
 ]);
 
-$symbolToString = SymbolToString;
+// -------------------------------------------------------------------
+// Exports
+
+utils.Export(function(to) {
+  to.SymbolToString = SymbolToString;
+})
 
 })
index d1f7ed1..416fd68 100644 (file)
@@ -15,6 +15,8 @@ var GlobalArray = global.Array;
 var GlobalArrayBuffer = global.ArrayBuffer;
 var GlobalDataView = global.DataView;
 var GlobalObject = global.Object;
+var iteratorSymbol = utils.ImportNow("iterator_symbol");
+var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
 
 macro TYPED_ARRAYS(FUNCTION)
 // arrayIds below should be synchronized with Runtime_TypedArrayInitialize.
@@ -147,7 +149,7 @@ function NAMEConstructByIterable(obj, iterable, iteratorFn) {
   };
   // TODO(littledan): Computed properties don't work yet in nosnap.
   // Rephrase when they do.
-  newIterable[symbolIterator] = function() { return iterator; }
+  newIterable[iteratorSymbol] = function() { return iterator; }
   for (var value of newIterable) {
     list.push(value);
   }
@@ -162,7 +164,7 @@ function NAMEConstructor(arg1, arg2, arg3) {
                IS_BOOLEAN(arg1) || IS_UNDEFINED(arg1)) {
       NAMEConstructByLength(this, arg1);
     } else {
-      var iteratorFn = arg1[symbolIterator];
+      var iteratorFn = arg1[iteratorSymbol];
       if (IS_UNDEFINED(iteratorFn) || iteratorFn === $arrayValues) {
         NAMEConstructByArrayLike(this, arg1);
       } else {
@@ -368,7 +370,7 @@ macro SETUP_TYPED_ARRAY(ARRAY_ID, NAME, ELEMENT_SIZE)
                       DONT_ENUM | DONT_DELETE);
   utils.InstallGetter(GlobalNAME.prototype, "length", NAME_GetLength,
                       DONT_ENUM | DONT_DELETE);
-  utils.InstallGetter(GlobalNAME.prototype, symbolToStringTag,
+  utils.InstallGetter(GlobalNAME.prototype, toStringTagSymbol,
                       TypedArrayGetToStringTag);
   utils.InstallFunctions(GlobalNAME.prototype, DONT_ENUM, [
     "subarray", NAMESubArray,
@@ -474,7 +476,7 @@ DATA_VIEW_TYPES(DATA_VIEW_GETTER_SETTER)
 // Set up constructor property on the DataView prototype.
 %AddNamedProperty(GlobalDataView.prototype, "constructor", GlobalDataView,
                   DONT_ENUM);
-%AddNamedProperty(GlobalDataView.prototype, symbolToStringTag, "DataView",
+%AddNamedProperty(GlobalDataView.prototype, toStringTagSymbol, "DataView",
                   READ_ONLY|DONT_ENUM);
 
 utils.InstallGetter(GlobalDataView.prototype, "buffer", DataViewGetBufferJS);
index 4a9cf54..fbe6957 100644 (file)
@@ -9,20 +9,23 @@
 // ----------------------------------------------------------------------------
 // Imports
 
+var FLAG_harmony_tostring;
 var GlobalArray = global.Array;
 var GlobalBoolean = global.Boolean;
 var GlobalFunction = global.Function;
 var GlobalNumber = global.Number;
 var GlobalObject = global.Object;
 var InternalArray = utils.InternalArray;
+var iteratorSymbol = utils.ImportNow("iterator_symbol");
 var MathAbs;
 var ProxyDelegateCallAndConstruct;
 var ProxyDerivedHasOwnTrap;
 var ProxyDerivedKeysTrap;
 var StringIndexOf;
-var ToBoolean;
-var ToNumber;
+var ToBoolean = utils.ImportNow("ToBoolean");
+var ToNumber = utils.ImportNow("ToNumber");
 var ToString;
+var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
 
 utils.Import(function(from) {
   MathAbs = from.MathAbs;
@@ -30,12 +33,8 @@ utils.Import(function(from) {
   ToString = from.ToString;
 });
 
-utils.ImportNow(function(from) {
-  ToBoolean = from.ToBoolean;
-  ToNumber = from.ToNumber;
-});
-
 utils.ImportFromExperimental(function(from) {
+  FLAG_harmony_tostring = from.FLAG_harmony_tostring;
   ProxyDelegateCallAndConstruct = from.ProxyDelegateCallAndConstruct;
   ProxyDerivedHasOwnTrap = from.ProxyDerivedHasOwnTrap;
   ProxyDerivedKeysTrap = from.ProxyDerivedKeysTrap;
@@ -148,8 +147,8 @@ function ObjectToString() {
   var tag;
 
   // TODO(caitp): cannot wait to get rid of this flag :>
-  if (harmony_tostring) {
-    tag = O[symbolToStringTag];
+  if (FLAG_harmony_tostring) {
+    tag = O[toStringTagSymbol];
     if (!IS_STRING(tag)) {
       tag = builtinTag;
     }
@@ -1773,7 +1772,7 @@ utils.InstallFunctions(GlobalFunction.prototype, DONT_ENUM, [
 // 7.4.1 GetIterator ( obj, method )
 function GetIterator(obj, method) {
   if (IS_UNDEFINED(method)) {
-    method = obj[symbolIterator];
+    method = obj[iteratorSymbol];
   }
   if (!IS_SPEC_FUNCTION(method)) {
     throw MakeTypeError(kNotIterable, obj);
index 7535093..933d753 100644 (file)
@@ -11,6 +11,7 @@
 var GlobalObject = global.Object;
 var GlobalWeakMap = global.WeakMap;
 var GlobalWeakSet = global.WeakSet;
+var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
 
 // -------------------------------------------------------------------
 // Harmony WeakMap
@@ -90,7 +91,7 @@ function WeakMapDelete(key) {
 %FunctionSetPrototype(GlobalWeakMap, new GlobalObject());
 %AddNamedProperty(GlobalWeakMap.prototype, "constructor", GlobalWeakMap,
                   DONT_ENUM);
-%AddNamedProperty(GlobalWeakMap.prototype, symbolToStringTag, "WeakMap",
+%AddNamedProperty(GlobalWeakMap.prototype, toStringTagSymbol, "WeakMap",
                   DONT_ENUM | READ_ONLY);
 
 // Set up the non-enumerable functions on the WeakMap prototype object.
@@ -164,7 +165,7 @@ function WeakSetDelete(value) {
 %FunctionSetPrototype(GlobalWeakSet, new GlobalObject());
 %AddNamedProperty(GlobalWeakSet.prototype, "constructor", GlobalWeakSet,
                  DONT_ENUM);
-%AddNamedProperty(GlobalWeakSet.prototype, symbolToStringTag, "WeakSet",
+%AddNamedProperty(GlobalWeakSet.prototype, toStringTagSymbol, "WeakSet",
                   DONT_ENUM | READ_ONLY);
 
 // Set up the non-enumerable functions on the WeakSet prototype object.