Call JS functions via native context instead of js builtins object.
authoryangguo <yangguo@chromium.org>
Wed, 26 Aug 2015 11:16:38 +0000 (04:16 -0700)
committerCommit bot <commit-bot@chromium.org>
Wed, 26 Aug 2015 11:16:57 +0000 (11:16 +0000)
We look up %-functions in the context if not found in the runtime.

R=bmeurer@chromium.org, mstarzinger@chromium.org

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

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

46 files changed:
src/array-iterator.js
src/assembler.cc
src/ast-value-factory.h
src/ast.h
src/bootstrapper.cc
src/bootstrapper.h
src/code-stubs-hydrogen.cc
src/collection.js
src/compiler/ast-graph-builder.cc
src/contexts.cc
src/contexts.h
src/date.js
src/full-codegen/arm/full-codegen-arm.cc
src/full-codegen/arm64/full-codegen-arm64.cc
src/full-codegen/ia32/full-codegen-ia32.cc
src/full-codegen/mips/full-codegen-mips.cc
src/full-codegen/mips64/full-codegen-mips64.cc
src/full-codegen/ppc/full-codegen-ppc.cc
src/full-codegen/x64/full-codegen-x64.cc
src/full-codegen/x87/full-codegen-x87.cc
src/harmony-reflect.js
src/harmony-spread.js
src/hydrogen-instructions.cc
src/hydrogen-instructions.h
src/hydrogen.cc
src/hydrogen.h
src/json.js
src/messages.js
src/object-observe.js
src/parser.cc
src/pattern-rewriter.cc
src/prettyprinter.cc
src/prologue.js
src/promise.js
src/proxy.js
src/regexp.js
src/runtime.js
src/runtime/runtime-internal.cc
src/runtime/runtime-scopes.cc
src/runtime/runtime.cc
src/runtime/runtime.h
src/templates.js
src/v8natives.js
test/cctest/compiler/test-run-jscalls.cc
test/cctest/test-parsing.cc
test/mjsunit/compiler/jsnatives.js

index df74aa85c40adf5a89472e0c2e93a3e2f7935693..67f1eeff9ed4eca712dec66247eb821d76d75f39 100644 (file)
@@ -170,8 +170,6 @@ utils.Export(function(to) {
 
 $arrayValues = ArrayValues;
 
-utils.ExportToRuntime(function(to) {
-  to["array_values_iterator"] = ArrayValues;
-});
+%InstallToContext(["array_values_iterator", ArrayValues]);
 
 })
index fa7c26b17b8ab51d3ce441a4771607b3678751bb..aabc64ba5c71ba8ef6f5bcc1c991666c787d6ab7 100644 (file)
@@ -980,14 +980,13 @@ ExternalReference::ExternalReference(Builtins::Name name, Isolate* isolate)
   : address_(isolate->builtins()->builtin_address(name)) {}
 
 
-ExternalReference::ExternalReference(Runtime::FunctionId id,
-                                     Isolate* isolate)
-  : address_(Redirect(isolate, Runtime::FunctionForId(id)->entry)) {}
+ExternalReference::ExternalReference(Runtime::FunctionId id, Isolate* isolate)
+    : address_(Redirect(isolate, Runtime::FunctionForId(id)->entry)) {}
 
 
 ExternalReference::ExternalReference(const Runtime::Function* f,
                                      Isolate* isolate)
-  : address_(Redirect(isolate, f->entry)) {}
+    : address_(Redirect(isolate, f->entry)) {}
 
 
 ExternalReference ExternalReference::isolate_address(Isolate* isolate) {
index efc3b20c25eaf6f7f91567a223e54401246eb2ef..81002e68ca201bd9616990b870e08b74f02bd442 100644 (file)
@@ -244,7 +244,6 @@ class AstValue : public ZoneObject {
 #define STRING_CONSTANTS(F)                                                \
   F(anonymous_function, "(anonymous function)")                            \
   F(arguments, "arguments")                                                \
-  F(concat_iterable_to_array, "$concatIterableToArray")                    \
   F(constructor, "constructor")                                            \
   F(default, "default")                                                    \
   F(done, "done")                                                          \
@@ -258,25 +257,14 @@ class AstValue : public ZoneObject {
   F(dot_switch_tag, ".switch_tag")                                         \
   F(empty, "")                                                             \
   F(eval, "eval")                                                          \
-  F(get_template_callsite, "$getTemplateCallSite")                         \
-  F(initialize_const_global, "initializeConstGlobal")                      \
-  F(initialize_var_global, "initializeVarGlobal")                          \
-  F(is_construct_call, "_IsConstructCall")                                 \
-  F(is_spec_object, "_IsSpecObject")                                       \
   F(let, "let")                                                            \
   F(native, "native")                                                      \
   F(new_target, ".new.target")                                             \
   F(next, "next")                                                          \
   F(proto, "__proto__")                                                    \
   F(prototype, "prototype")                                                \
-  F(reflect_apply, "$reflectApply")                                        \
-  F(reflect_construct, "$reflectConstruct")                                \
-  F(spread_arguments, "$spreadArguments")                                  \
-  F(spread_iterable, "$spreadIterable")                                    \
   F(this, "this")                                                          \
   F(this_function, ".this_function")                                       \
-  F(throw_iterator_result_not_an_object, "ThrowIteratorResultNotAnObject") \
-  F(to_string, "$toString")                                                \
   F(undefined, "undefined")                                                \
   F(use_asm, "use asm")                                                    \
   F(use_strong, "use strong")                                              \
index aa9cbb915165a480e785a051f1987c4b3758e033..7eb73d9023547f9587a95aec5d64d6153c8b2fdb 100644 (file)
--- a/src/ast.h
+++ b/src/ast.h
@@ -2032,51 +2032,45 @@ class CallRuntime final : public Expression {
  public:
   DECLARE_NODE_TYPE(CallRuntime)
 
-  Handle<String> name() const { return raw_name_->string(); }
-  const AstRawString* raw_name() const { return raw_name_; }
-  const Runtime::Function* function() const { return function_; }
   ZoneList<Expression*>* arguments() const { return arguments_; }
   bool is_jsruntime() const { return function_ == NULL; }
 
-  // Type feedback information.
-  bool HasCallRuntimeFeedbackSlot() const { return is_jsruntime(); }
-  virtual FeedbackVectorRequirements ComputeFeedbackRequirements(
-      Isolate* isolate, const ICSlotCache* cache) override {
-    return FeedbackVectorRequirements(0, HasCallRuntimeFeedbackSlot() ? 1 : 0);
-  }
-  void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot,
-                              ICSlotCache* cache) override {
-    callruntime_feedback_slot_ = slot;
+  int context_index() const {
+    DCHECK(is_jsruntime());
+    return context_index_;
   }
-  Code::Kind FeedbackICSlotKind(int index) override { return Code::LOAD_IC; }
-
-  FeedbackVectorICSlot CallRuntimeFeedbackSlot() {
-    DCHECK(!HasCallRuntimeFeedbackSlot() ||
-           !callruntime_feedback_slot_.IsInvalid());
-    return callruntime_feedback_slot_;
+  const Runtime::Function* function() const {
+    DCHECK(!is_jsruntime());
+    return function_;
   }
 
   static int num_ids() { return parent_num_ids() + 1; }
   BailoutId CallId() { return BailoutId(local_id(0)); }
 
+  const char* debug_name() {
+    return is_jsruntime() ? "(context function)" : function_->name;
+  }
+
  protected:
-  CallRuntime(Zone* zone, const AstRawString* name,
-              const Runtime::Function* function,
+  CallRuntime(Zone* zone, const Runtime::Function* function,
               ZoneList<Expression*>* arguments, int pos)
+      : Expression(zone, pos), function_(function), arguments_(arguments) {}
+
+  CallRuntime(Zone* zone, int context_index, ZoneList<Expression*>* arguments,
+              int pos)
       : Expression(zone, pos),
-        raw_name_(name),
-        function_(function),
-        arguments_(arguments),
-        callruntime_feedback_slot_(FeedbackVectorICSlot::Invalid()) {}
+        function_(NULL),
+        context_index_(context_index),
+        arguments_(arguments) {}
+
   static int parent_num_ids() { return Expression::num_ids(); }
 
  private:
   int local_id(int n) const { return base_id() + parent_num_ids() + n; }
 
-  const AstRawString* raw_name_;
   const Runtime::Function* function_;
+  int context_index_;
   ZoneList<Expression*>* arguments_;
-  FeedbackVectorICSlot callruntime_feedback_slot_;
 };
 
 
@@ -3521,11 +3515,20 @@ class AstNodeFactory final BASE_EMBEDDED {
     return new (zone_) CallNew(zone_, expression, arguments, pos);
   }
 
-  CallRuntime* NewCallRuntime(const AstRawString* name,
-                              const Runtime::Function* function,
-                              ZoneList<Expression*>* arguments,
-                              int pos) {
-    return new (zone_) CallRuntime(zone_, name, function, arguments, pos);
+  CallRuntime* NewCallRuntime(Runtime::FunctionId id,
+                              ZoneList<Expression*>* arguments, int pos) {
+    return new (zone_)
+        CallRuntime(zone_, Runtime::FunctionForId(id), arguments, pos);
+  }
+
+  CallRuntime* NewCallRuntime(const Runtime::Function* function,
+                              ZoneList<Expression*>* arguments, int pos) {
+    return new (zone_) CallRuntime(zone_, function, arguments, pos);
+  }
+
+  CallRuntime* NewCallRuntime(int context_index,
+                              ZoneList<Expression*>* arguments, int pos) {
+    return new (zone_) CallRuntime(zone_, context_index, arguments, pos);
   }
 
   UnaryOperation* NewUnaryOperation(Token::Value op,
index eb7400ae7fe8571b2013c03734a8965dd9aec959..7d29218a4532dab950173249e8ee601c3aead4f8 100644 (file)
@@ -1752,75 +1752,6 @@ void Genesis::InitializeBuiltinTypedArrays() {
 }
 
 
-#define INSTALL_NATIVE(index, Type, name)                    \
-  Handle<Object> name##_native =                             \
-      Object::GetProperty(isolate, container, #name, STRICT) \
-          .ToHandleChecked();                                \
-  DCHECK(name##_native->Is##Type());                         \
-  native_context->set_##name(Type::cast(*name##_native));
-
-
-void Bootstrapper::ImportNatives(Isolate* isolate, Handle<JSObject> container) {
-  HandleScope scope(isolate);
-  Handle<Context> native_context = isolate->native_context();
-  NATIVE_CONTEXT_IMPORTED_FIELDS(INSTALL_NATIVE)
-}
-
-
-#define EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(id)                                \
-  static void InstallExperimentalNatives_##id(Isolate* isolate,               \
-                                              Handle<Context> native_context, \
-                                              Handle<JSObject> container) {}
-
-EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_modules)
-EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_array_includes)
-EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_regexps)
-EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_arrow_functions)
-EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_tostring)
-EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_sloppy)
-EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_sloppy_function)
-EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_sloppy_let)
-EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_unicode_regexps)
-EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_rest_parameters)
-EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_default_parameters)
-EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_reflect)
-EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_spreadcalls)
-EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_destructuring)
-EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_object)
-EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_object_observe)
-EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_spread_arrays)
-EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_sharedarraybuffer)
-EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_atomics)
-EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_new_target)
-EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_concat_spreadable)
-EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_simd)
-
-
-static void InstallExperimentalNatives_harmony_proxies(
-    Isolate* isolate, Handle<Context> native_context,
-    Handle<JSObject> container) {
-  if (FLAG_harmony_proxies) {
-    NATIVE_CONTEXT_IMPORTED_FIELDS_FOR_PROXY(INSTALL_NATIVE)
-  }
-}
-
-
-void Bootstrapper::ImportExperimentalNatives(Isolate* isolate,
-                                             Handle<JSObject> container) {
-  HandleScope scope(isolate);
-  Handle<Context> native_context = isolate->native_context();
-#define INSTALL_NATIVE_FUNCTIONS_FOR(id, descr) \
-  InstallExperimentalNatives_##id(isolate, native_context, container);
-
-  HARMONY_INPROGRESS(INSTALL_NATIVE_FUNCTIONS_FOR)
-  HARMONY_STAGED(INSTALL_NATIVE_FUNCTIONS_FOR)
-  HARMONY_SHIPPING(INSTALL_NATIVE_FUNCTIONS_FOR)
-#undef INSTALL_NATIVE_FUNCTIONS_FOR
-}
-
-#undef INSTALL_NATIVE
-
-
 bool Bootstrapper::InstallJSBuiltins(Isolate* isolate,
                                      Handle<JSObject> container) {
   HandleScope scope(isolate);
@@ -1905,12 +1836,16 @@ void Genesis::InitializeGlobal_harmony_reflect() {
   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(
index 610610ba2bef61124bb6ce383108e7d9100418d6..28cb1d64a21061b55938a4f0d4a1cd33ada12e8f 100644 (file)
@@ -119,9 +119,6 @@ class Bootstrapper final {
   static bool CompileCodeStubBuiltin(Isolate* isolate, int index);
   static bool InstallCodeStubNatives(Isolate* isolate);
 
-  static void ImportNatives(Isolate* isolate, Handle<JSObject> container);
-  static void ImportExperimentalNatives(Isolate* isolate,
-                                        Handle<JSObject> container);
   static bool InstallJSBuiltins(Isolate* isolate, Handle<JSObject> container);
   static void ExportPrivateSymbols(Isolate* isolate,
                                    Handle<JSObject> container);
index 0a48ad468eb3b8c37d7001e68e15239a0f7a89b0..3901ef8026c58fbff5f65cbf8e49efb604362482 100644 (file)
@@ -2191,7 +2191,6 @@ HValue* CodeStubGraphBuilder<KeyedLoadGenericStub>::BuildCodeStub() {
         // KeyedLookupCache miss; call runtime.
         Add<HPushArguments>(receiver, key);
         Push(Add<HCallRuntime>(
-            isolate()->factory()->empty_string(),
             Runtime::FunctionForId(is_strong(casted_stub()->language_mode())
                                        ? Runtime::kKeyedGetPropertyStrong
                                        : Runtime::kKeyedGetProperty),
index 4dff566049d9f01d54374c53cffd0bad93efb94a..718ca9be67e3d3d4e12277429a1e3c7eda3efaf0 100644 (file)
@@ -502,16 +502,16 @@ function SetFromArray(array) {
 // -----------------------------------------------------------------------
 // Exports
 
-utils.ExportToRuntime(function(to) {
-  to["map_get"] = MapGet;
-  to["map_set"] = MapSet;
-  to["map_has"] = MapHas;
-  to["map_delete"] = MapDelete;
-  to["set_add"] = SetAdd;
-  to["set_has"] = SetHas;
-  to["set_delete"] = SetDelete;
-  to["map_from_array"] = MapFromArray;
-  to["set_from_array"]= SetFromArray;
-});
+%InstallToContext([
+  "map_get", MapGet,
+  "map_set", MapSet,
+  "map_has", MapHas,
+  "map_delete", MapDelete,
+  "set_add", SetAdd,
+  "set_has", SetHas,
+  "set_delete", SetDelete,
+  "map_from_array", MapFromArray,
+  "set_from_array",SetFromArray,
+]);
 
 })
index 255e231f661e4c1fb4ef7404582f506e70fec386..fca0388327547a05bee59ccafba59e97cc2b7ad9 100644 (file)
@@ -2538,18 +2538,17 @@ void AstGraphBuilder::VisitCallNew(CallNew* expr) {
 
 
 void AstGraphBuilder::VisitCallJSRuntime(CallRuntime* expr) {
-  Handle<String> name = expr->name();
-
   // The callee and the receiver both have to be pushed onto the operand stack
   // before arguments are being evaluated.
   CallFunctionFlags flags = NO_CALL_FUNCTION_FLAGS;
-  Node* receiver_value = BuildLoadBuiltinsObject();
-  VectorSlotPair pair = CreateVectorSlotPair(expr->CallRuntimeFeedbackSlot());
-  // TODO(jarin): bailout ids for runtime calls.
-  FrameStateBeforeAndAfter states(this, BailoutId::None());
-  Node* callee_value = BuildNamedLoad(receiver_value, name, pair);
-  states.AddToNode(callee_value, BailoutId::None(),
-                   OutputFrameStateCombine::Push());
+  Node* global = BuildLoadGlobalObject();
+  Node* native_context =
+      BuildLoadObjectField(global, GlobalObject::kNativeContextOffset);
+  Node* callee_value =
+      NewNode(javascript()->LoadContext(0, expr->context_index(), true),
+              native_context);
+  Node* receiver_value = jsgraph()->UndefinedConstant();
+
   environment()->Push(callee_value);
   environment()->Push(receiver_value);
 
@@ -2567,15 +2566,14 @@ void AstGraphBuilder::VisitCallJSRuntime(CallRuntime* expr) {
 
 
 void AstGraphBuilder::VisitCallRuntime(CallRuntime* expr) {
-  const Runtime::Function* function = expr->function();
-
   // Handle calls to runtime functions implemented in JavaScript separately as
   // the call follows JavaScript ABI and the callee is statically unknown.
   if (expr->is_jsruntime()) {
-    DCHECK(function == NULL && expr->name()->length() > 0);
     return VisitCallJSRuntime(expr);
   }
 
+  const Runtime::Function* function = expr->function();
+
   // TODO(mstarzinger): This bailout is a gigantic hack, the owner is ashamed.
   if (function->function_id == Runtime::kInlineGeneratorNext ||
       function->function_id == Runtime::kInlineGeneratorThrow) {
index e3ace3c8c1e967a87d049578b6dc082e1bf8c6cf..0e89821c7f683e63517c5f0d003aac3d3896e1a4 100644 (file)
@@ -244,7 +244,7 @@ Handle<Object> Context::Lookup(Handle<String> name,
   Handle<Context> context(this, isolate);
 
   bool follow_context_chain = (flags & FOLLOW_CONTEXT_CHAIN) != 0;
-  *index = -1;
+  *index = kNotFound;
   *attributes = ABSENT;
   *binding_flags = MISSING_BINDING;
 
@@ -537,6 +537,23 @@ Handle<Object> Context::ErrorMessageForCodeGenerationFromStrings() {
 }
 
 
+#define COMPARE_NAME(index, type, name) \
+  if (string->IsOneByteEqualTo(STATIC_CHAR_VECTOR(#name))) return index;
+
+int Context::ImportedFieldIndexForName(Handle<String> string) {
+  NATIVE_CONTEXT_IMPORTED_FIELDS(COMPARE_NAME)
+  return kNotFound;
+}
+
+
+int Context::IntrinsicIndexForName(Handle<String> string) {
+  NATIVE_CONTEXT_INTRINSIC_FUNCTIONS(COMPARE_NAME);
+  return kNotFound;
+}
+
+#undef COMPARE_NAME
+
+
 #ifdef DEBUG
 bool Context::IsBootstrappingOrValidParentContext(
     Object* object, Context* child) {
index 2dd03bc66a5bcf53b0c3a95c2912751c486aad26..1a35ed9ae4895918738d18ad7e0626776a554534 100644 (file)
@@ -73,9 +73,29 @@ enum BindingFlags {
 // must always be allocated via Heap::AllocateContext() or
 // Factory::NewContext.
 
+#define NATIVE_CONTEXT_INTRINSIC_FUNCTIONS(V)                             \
+  V(CONCAT_ITERABLE_TO_ARRAY_INDEX, JSFunction, concat_iterable_to_array) \
+  V(GET_TEMPLATE_CALL_SITE_INDEX, JSFunction, get_template_call_site)     \
+  V(MAKE_RANGE_ERROR_INDEX, JSFunction, make_range_error)                 \
+  V(MAKE_TYPE_ERROR_INDEX, JSFunction, make_type_error)                   \
+  V(NON_NUMBER_TO_NUMBER_INDEX, JSFunction, non_number_to_number)         \
+  V(NON_STRING_TO_STRING_INDEX, JSFunction, non_string_to_string)         \
+  V(REFLECT_APPLY_INDEX, JSFunction, reflect_apply)                       \
+  V(REFLECT_CONSTRUCT_INDEX, JSFunction, reflect_construct)               \
+  V(SPREAD_ARGUMENTS_INDEX, JSFunction, spread_arguments)                 \
+  V(SPREAD_ITERABLE_INDEX, JSFunction, spread_iterable)                   \
+  V(TO_LENGTH_FUN_INDEX, JSFunction, to_length_fun)                       \
+  V(TO_NAME_INDEX, JSFunction, to_name)                                   \
+  V(TO_NUMBER_FUN_INDEX, JSFunction, to_number_fun)                       \
+  V(TO_PRIMITIVE_INDEX, JSFunction, to_primitive)                         \
+  V(TO_STRING_FUN_INDEX, JSFunction, to_string_fun)
+
 #define NATIVE_CONTEXT_IMPORTED_FIELDS(V)                                     \
   V(ARRAY_VALUES_ITERATOR_INDEX, JSFunction, array_values_iterator)           \
   V(CREATE_DATE_FUN_INDEX, JSFunction, create_date_fun)                       \
+  V(DERIVED_GET_TRAP_INDEX, JSFunction, derived_get_trap)                     \
+  V(DERIVED_HAS_TRAP_INDEX, JSFunction, derived_has_trap)                     \
+  V(DERIVED_SET_TRAP_INDEX, JSFunction, derived_set_trap)                     \
   V(ERROR_FUNCTION_INDEX, JSFunction, error_function)                         \
   V(EVAL_ERROR_FUNCTION_INDEX, JSFunction, eval_error_function)               \
   V(GET_STACK_TRACE_LINE_INDEX, JSFunction, get_stack_trace_line_fun)         \
@@ -111,6 +131,7 @@ enum BindingFlags {
   V(PROMISE_REJECT_INDEX, JSFunction, promise_reject)                         \
   V(PROMISE_RESOLVE_INDEX, JSFunction, promise_resolve)                       \
   V(PROMISE_THEN_INDEX, JSFunction, promise_then)                             \
+  V(PROXY_ENUMERATE_INDEX, JSFunction, proxy_enumerate)                       \
   V(RANGE_ERROR_FUNCTION_INDEX, JSFunction, range_error_function)             \
   V(REFERENCE_ERROR_FUNCTION_INDEX, JSFunction, reference_error_function)     \
   V(SET_ADD_METHOD_INDEX, JSFunction, set_add)                                \
@@ -123,18 +144,9 @@ enum BindingFlags {
     to_complete_property_descriptor)                                          \
   V(TO_DETAIL_STRING_FUN_INDEX, JSFunction, to_detail_string_fun)             \
   V(TO_INTEGER_FUN_INDEX, JSFunction, to_integer_fun)                         \
-  V(TO_LENGTH_FUN_INDEX, JSFunction, to_length_fun)                           \
-  V(TO_NUMBER_FUN_INDEX, JSFunction, to_number_fun)                           \
-  V(TO_STRING_FUN_INDEX, JSFunction, to_string_fun)                           \
   V(TYPE_ERROR_FUNCTION_INDEX, JSFunction, type_error_function)               \
   V(URI_ERROR_FUNCTION_INDEX, JSFunction, uri_error_function)
 
-#define NATIVE_CONTEXT_IMPORTED_FIELDS_FOR_PROXY(V)       \
-  V(DERIVED_GET_TRAP_INDEX, JSFunction, derived_get_trap) \
-  V(DERIVED_HAS_TRAP_INDEX, JSFunction, derived_has_trap) \
-  V(DERIVED_SET_TRAP_INDEX, JSFunction, derived_set_trap) \
-  V(PROXY_ENUMERATE_INDEX, JSFunction, proxy_enumerate)
-
 #define NATIVE_CONTEXT_FIELDS(V)                                               \
   V(GLOBAL_PROXY_INDEX, JSObject, global_proxy_object)                         \
   V(EMBEDDER_DATA_INDEX, FixedArray, embedder_data)                            \
@@ -222,8 +234,8 @@ enum BindingFlags {
   V(UINT8_ARRAY_FUN_INDEX, JSFunction, uint8_array_fun)                        \
   V(UINT8_CLAMPED_ARRAY_FUN_INDEX, JSFunction, uint8_clamped_array_fun)        \
   V(UINT8X16_FUNCTION_INDEX, JSFunction, uint8x16_function)                    \
-  NATIVE_CONTEXT_IMPORTED_FIELDS(V)                                            \
-  NATIVE_CONTEXT_IMPORTED_FIELDS_FOR_PROXY(V)
+  NATIVE_CONTEXT_INTRINSIC_FUNCTIONS(V)                                        \
+  NATIVE_CONTEXT_IMPORTED_FIELDS(V)
 
 // A table of all script contexts. Every loaded top-level script with top-level
 // lexical declarations contributes its ScriptContext into this table.
@@ -476,6 +488,9 @@ class Context: public FixedArray {
 
   Handle<Object> ErrorMessageForCodeGenerationFromStrings();
 
+  static int ImportedFieldIndexForName(Handle<String> name);
+  static int IntrinsicIndexForName(Handle<String> name);
+
 #define NATIVE_CONTEXT_FIELD_ACCESSORS(index, type, name) \
   void  set_##name(type* value) {                         \
     DCHECK(IsNativeContext());                            \
@@ -546,6 +561,7 @@ class Context: public FixedArray {
   }
 
   static const int kSize = kHeaderSize + NATIVE_CONTEXT_SLOTS * kPointerSize;
+  static const int kNotFound = -1;
 
   // GC support.
   typedef FixedBodyDescriptor<
index 3d0693a56f15d4a1c73b0ceb5a11d7aa22b2be6d..2be8bcb220a7f3ed91ea1fb6943fa79398d5e4a7 100644 (file)
@@ -883,8 +883,6 @@ utils.InstallFunctions(GlobalDate.prototype, DONT_ENUM, [
   "toJSON", DateToJSON
 ]);
 
-utils.ExportToRuntime(function(to) {
-  to["create_date_fun"] = CreateDate;
-});
+%InstallToContext(["create_date_fun", CreateDate]);
 
 })
index c774b6d9aea56cd1b7c184546c778986de42f03d..f839af696ac8102350572f47af26cb431d1b6b19 100644 (file)
@@ -4531,17 +4531,13 @@ void FullCodeGenerator::EmitDebugIsActive(CallRuntime* expr) {
 
 
 void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) {
-  // Push the builtins object as the receiver.
-  Register receiver = LoadDescriptor::ReceiverRegister();
-  __ ldr(receiver, GlobalObjectOperand());
-  __ ldr(receiver, FieldMemOperand(receiver, GlobalObject::kBuiltinsOffset));
-  __ push(receiver);
+  // Push undefined as the receiver.
+  __ LoadRoot(r0, Heap::kUndefinedValueRootIndex);
+  __ push(r0);
 
-  // Load the function from the receiver.
-  __ mov(LoadDescriptor::NameRegister(), Operand(expr->name()));
-  __ mov(LoadDescriptor::SlotRegister(),
-         Operand(SmiFromSlot(expr->CallRuntimeFeedbackSlot())));
-  CallLoadIC(NOT_INSIDE_TYPEOF);
+  __ ldr(r0, GlobalObjectOperand());
+  __ ldr(r0, FieldMemOperand(r0, GlobalObject::kNativeContextOffset));
+  __ ldr(r0, ContextOperand(r0, expr->context_index()));
 }
 
 
index 6d98c15d3cf16f9156d25777ee1ed36b69da910d..58f1a39521b4994ad843f17afcc9e903793e6acb 100644 (file)
@@ -4227,18 +4227,13 @@ void FullCodeGenerator::EmitDebugIsActive(CallRuntime* expr) {
 
 
 void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) {
-  // Push the builtins object as the receiver.
-  __ Ldr(x10, GlobalObjectMemOperand());
-  __ Ldr(LoadDescriptor::ReceiverRegister(),
-         FieldMemOperand(x10, GlobalObject::kBuiltinsOffset));
-  __ Push(LoadDescriptor::ReceiverRegister());
+  // Push undefined as the receiver.
+  __ LoadRoot(x0, Heap::kUndefinedValueRootIndex);
+  __ Push(x0);
 
-  // Load the function from the receiver.
-  Handle<String> name = expr->name();
-  __ Mov(LoadDescriptor::NameRegister(), Operand(name));
-  __ Mov(LoadDescriptor::SlotRegister(),
-         SmiFromSlot(expr->CallRuntimeFeedbackSlot()));
-  CallLoadIC(NOT_INSIDE_TYPEOF);
+  __ Ldr(x0, GlobalObjectMemOperand());
+  __ Ldr(x0, FieldMemOperand(x0, GlobalObject::kNativeContextOffset));
+  __ Ldr(x0, ContextMemOperand(x0, expr->context_index()));
 }
 
 
index bbb5d6991a748953806de614b08d99ab535fa926..caa27cf15786a91c0156e7260f5eb0bf3960eef6 100644 (file)
@@ -4469,16 +4469,12 @@ void FullCodeGenerator::EmitDebugIsActive(CallRuntime* expr) {
 
 
 void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) {
-  // Push the builtins object as receiver.
-  __ mov(eax, GlobalObjectOperand());
-  __ push(FieldOperand(eax, GlobalObject::kBuiltinsOffset));
+  // Push undefined as receiver.
+  __ push(Immediate(isolate()->factory()->undefined_value()));
 
-  // Load the function from the receiver.
-  __ mov(LoadDescriptor::ReceiverRegister(), Operand(esp, 0));
-  __ mov(LoadDescriptor::NameRegister(), Immediate(expr->name()));
-  __ mov(LoadDescriptor::SlotRegister(),
-         Immediate(SmiFromSlot(expr->CallRuntimeFeedbackSlot())));
-  CallLoadIC(NOT_INSIDE_TYPEOF);
+  __ mov(eax, GlobalObjectOperand());
+  __ mov(eax, FieldOperand(eax, GlobalObject::kNativeContextOffset));
+  __ mov(eax, ContextOperand(eax, expr->context_index()));
 }
 
 
index b39f698e4a8b5b39a958d0751efcba0f4d3af636..a171f725404861445e16987b422112421d174182 100644 (file)
@@ -4553,17 +4553,13 @@ void FullCodeGenerator::EmitDebugIsActive(CallRuntime* expr) {
 
 
 void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) {
-  // Push the builtins object as the receiver.
-  Register receiver = LoadDescriptor::ReceiverRegister();
-  __ lw(receiver, GlobalObjectOperand());
-  __ lw(receiver, FieldMemOperand(receiver, GlobalObject::kBuiltinsOffset));
-  __ push(receiver);
+  // Push undefined as the receiver.
+  __ LoadRoot(v0, Heap::kUndefinedValueRootIndex);
+  __ push(v0);
 
-  // Load the function from the receiver.
-  __ li(LoadDescriptor::NameRegister(), Operand(expr->name()));
-  __ li(LoadDescriptor::SlotRegister(),
-        Operand(SmiFromSlot(expr->CallRuntimeFeedbackSlot())));
-  CallLoadIC(NOT_INSIDE_TYPEOF);
+  __ lw(v0, GlobalObjectOperand());
+  __ lw(v0, FieldMemOperand(v0, GlobalObject::kNativeContextOffset));
+  __ lw(v0, ContextOperand(v0, expr->context_index()));
 }
 
 
index e39753d8e72bec33b7724e6b805b325d16e5e0dd..3af356ca650ddd38b76ffcb7358cd8b24416bfa4 100644 (file)
@@ -4556,17 +4556,13 @@ void FullCodeGenerator::EmitDebugIsActive(CallRuntime* expr) {
 
 
 void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) {
-  // Push the builtins object as the receiver.
-  Register receiver = LoadDescriptor::ReceiverRegister();
-  __ ld(receiver, GlobalObjectOperand());
-  __ ld(receiver, FieldMemOperand(receiver, GlobalObject::kBuiltinsOffset));
-  __ push(receiver);
+  // Push undefined as the receiver.
+  __ LoadRoot(v0, Heap::kUndefinedValueRootIndex);
+  __ push(v0);
 
-  // Load the function from the receiver.
-  __ li(LoadDescriptor::NameRegister(), Operand(expr->name()));
-  __ li(LoadDescriptor::SlotRegister(),
-        Operand(SmiFromSlot(expr->CallRuntimeFeedbackSlot())));
-  CallLoadIC(NOT_INSIDE_TYPEOF);
+  __ ld(v0, GlobalObjectOperand());
+  __ ld(v0, FieldMemOperand(v0, GlobalObject::kNativeContextOffset));
+  __ ld(v0, ContextOperand(v0, expr->context_index()));
 }
 
 
index 60ac0b58b5b00d79525f6c2964738609c5f14d22..9fd6aff785ab562cda18686083ac10b62850c932 100644 (file)
@@ -4556,17 +4556,13 @@ void FullCodeGenerator::EmitDebugIsActive(CallRuntime* expr) {
 
 
 void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) {
-  // Push the builtins object as the receiver.
-  Register receiver = LoadDescriptor::ReceiverRegister();
-  __ LoadP(receiver, GlobalObjectOperand());
-  __ LoadP(receiver, FieldMemOperand(receiver, GlobalObject::kBuiltinsOffset));
-  __ push(receiver);
+  // Push undefined as the receiver.
+  __ LoadRoot(r3, Heap::kUndefinedValueRootIndex);
+  __ push(r3);
 
-  // Load the function from the receiver.
-  __ mov(LoadDescriptor::NameRegister(), Operand(expr->name()));
-  __ mov(LoadDescriptor::SlotRegister(),
-         Operand(SmiFromSlot(expr->CallRuntimeFeedbackSlot())));
-  CallLoadIC(NOT_INSIDE_TYPEOF);
+  __ LoadP(r3, GlobalObjectOperand());
+  __ LoadP(r3, FieldMemOperand(r3, GlobalObject::kNativeContextOffset));
+  __ LoadP(r3, ContextOperand(r3, expr->context_index()));
 }
 
 
index 715678cc750c30263e1253cf5ade88d6727f6f6f..c9b8484128f947691fa6a64f581be1e604029966 100644 (file)
@@ -4481,15 +4481,11 @@ void FullCodeGenerator::EmitDebugIsActive(CallRuntime* expr) {
 
 void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) {
   // Push the builtins object as receiver.
-  __ movp(rax, GlobalObjectOperand());
-  __ Push(FieldOperand(rax, GlobalObject::kBuiltinsOffset));
+  __ PushRoot(Heap::kUndefinedValueRootIndex);
 
-  // Load the function from the receiver.
-  __ movp(LoadDescriptor::ReceiverRegister(), Operand(rsp, 0));
-  __ Move(LoadDescriptor::NameRegister(), expr->name());
-  __ Move(LoadDescriptor::SlotRegister(),
-          SmiFromSlot(expr->CallRuntimeFeedbackSlot()));
-  CallLoadIC(NOT_INSIDE_TYPEOF);
+  __ movp(rax, GlobalObjectOperand());
+  __ movp(rax, FieldOperand(rax, GlobalObject::kNativeContextOffset));
+  __ movp(rax, ContextOperand(rax, expr->context_index()));
 }
 
 
index 25b8171487f5a351b38836aa2d42fe832a6b4b6d..63ca4048f16c3182c6cb5eea1cae48a9822fb815 100644 (file)
@@ -4460,16 +4460,12 @@ void FullCodeGenerator::EmitDebugIsActive(CallRuntime* expr) {
 
 
 void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) {
-  // Push the builtins object as receiver.
-  __ mov(eax, GlobalObjectOperand());
-  __ push(FieldOperand(eax, GlobalObject::kBuiltinsOffset));
+  // Push undefined as receiver.
+  __ push(Immediate(isolate()->factory()->undefined_value()));
 
-  // Load the function from the receiver.
-  __ mov(LoadDescriptor::ReceiverRegister(), Operand(esp, 0));
-  __ mov(LoadDescriptor::NameRegister(), Immediate(expr->name()));
-  __ mov(LoadDescriptor::SlotRegister(),
-         Immediate(SmiFromSlot(expr->CallRuntimeFeedbackSlot())));
-  CallLoadIC(NOT_INSIDE_TYPEOF);
+  __ mov(eax, GlobalObjectOperand());
+  __ mov(eax, FieldOperand(eax, GlobalObject::kNativeContextOffset));
+  __ mov(eax, ContextOperand(eax, expr->context_index()));
 }
 
 
index 5ad63e1a5cebbd73ded1c50a6247a72e7006a99f..1e6a7d2b7a37bde8d094694b48abc72279fd14ad 100644 (file)
@@ -2,6 +2,9 @@
 // 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';
index bfd6acb3a1eaa3119cfc8117250d441a55425897..b271c7efe54e1ec114b66344f275adfe4be98761 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.
 
-var $spreadArguments;
-var $spreadIterable;
-
 (function(global, utils) {
 
 'use strict';
@@ -43,7 +40,12 @@ function SpreadIterable(collection) {
   return args;
 }
 
-$spreadArguments = SpreadArguments;
-$spreadIterable = SpreadIterable;
+// ----------------------------------------------------------------------------
+// Exports
+
+%InstallToContext([
+  "spread_arguments", SpreadArguments,
+  "spread_iterable", SpreadIterable,
+]);
 
 })
index cc48cc5d019ec29d153c64ebb1d26bd741d21b29..b0d944bb6e9dc3e8d24b29e1ce228cb9a275adf5 100644 (file)
@@ -1099,7 +1099,7 @@ std::ostream& HCallNewArray::PrintDataTo(std::ostream& os) const {  // NOLINT
 
 
 std::ostream& HCallRuntime::PrintDataTo(std::ostream& os) const {  // NOLINT
-  os << name()->ToCString().get() << " ";
+  os << function()->name << " ";
   if (save_doubles() == kSaveFPRegs) os << "[save doubles] ";
   return os << "#" << argument_count();
 }
index ddcf21a4d6c48a58de04d3667b191d43fd628f3d..c82bd98bdf0c6467dfecbb41177329c19a01fb26 100644 (file)
@@ -2473,16 +2473,13 @@ class HCallNewArray final : public HBinaryCall {
 
 class HCallRuntime final : public HCall<1> {
  public:
-  DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P3(HCallRuntime,
-                                              Handle<String>,
-                                              const Runtime::Function*,
-                                              int);
+  DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P2(HCallRuntime,
+                                              const Runtime::Function*, int);
 
   std::ostream& PrintDataTo(std::ostream& os) const override;  // NOLINT
 
   HValue* context() { return OperandAt(0); }
   const Runtime::Function* function() const { return c_function_; }
-  Handle<String> name() const { return name_; }
   SaveFPRegsMode save_doubles() const { return save_doubles_; }
   void set_save_doubles(SaveFPRegsMode save_doubles) {
     save_doubles_ = save_doubles;
@@ -2495,17 +2492,15 @@ class HCallRuntime final : public HCall<1> {
   DECLARE_CONCRETE_INSTRUCTION(CallRuntime)
 
  private:
-  HCallRuntime(HValue* context,
-               Handle<String> name,
-               const Runtime::Function* c_function,
+  HCallRuntime(HValue* context, const Runtime::Function* c_function,
                int argument_count)
-      : HCall<1>(argument_count), c_function_(c_function), name_(name),
+      : HCall<1>(argument_count),
+        c_function_(c_function),
         save_doubles_(kDontSaveFPRegs) {
     SetOperandAt(0, context);
   }
 
   const Runtime::Function* c_function_;
-  Handle<String> name_;
   SaveFPRegsMode save_doubles_;
 };
 
index 38271d37f6b12c55a342f7cb1d51289a317412e0..cc9d489a44494fa756c3731a9c460537433b1664 100644 (file)
@@ -1565,7 +1565,6 @@ void HGraphBuilder::BuildKeyedIndexCheck(HValue* key,
           internalized.Else();
           Add<HPushArguments>(key);
           HValue* intern_key = Add<HCallRuntime>(
-              isolate()->factory()->empty_string(),
               Runtime::FunctionForId(Runtime::kInternalizeString), 1);
           Push(intern_key);
 
@@ -1723,7 +1722,6 @@ HValue* HGraphBuilder::BuildUncheckedDictionaryElementLoad(
     // TODO(jkummerow): walk the prototype chain instead.
     Add<HPushArguments>(receiver, key);
     Push(Add<HCallRuntime>(
-        isolate()->factory()->empty_string(),
         Runtime::FunctionForId(is_strong(language_mode)
                                    ? Runtime::kKeyedGetPropertyStrong
                                    : Runtime::kKeyedGetProperty),
@@ -1786,7 +1784,6 @@ HValue* HGraphBuilder::BuildUncheckedDictionaryElementLoad(
     details_compare.Else();
     Add<HPushArguments>(receiver, key);
     Push(Add<HCallRuntime>(
-        isolate()->factory()->empty_string(),
         Runtime::FunctionForId(is_strong(language_mode)
                                    ? Runtime::kKeyedGetPropertyStrong
                                    : Runtime::kKeyedGetProperty),
@@ -2020,7 +2017,6 @@ HValue* HGraphBuilder::BuildNumberToString(HValue* object, Type* type) {
     // Cache miss, fallback to runtime.
     Add<HPushArguments>(object);
     Push(Add<HCallRuntime>(
-            isolate()->factory()->empty_string(),
             Runtime::FunctionForId(Runtime::kNumberToStringSkipCache),
             1));
   }
@@ -2436,8 +2432,7 @@ HValue* HGraphBuilder::BuildUncheckedStringAdd(
     {
       // Fallback to the runtime to add the two strings.
       Add<HPushArguments>(left, right);
-      Push(Add<HCallRuntime>(isolate()->factory()->empty_string(),
-                             Runtime::FunctionForId(Runtime::kStringAdd), 2));
+      Push(Add<HCallRuntime>(Runtime::FunctionForId(Runtime::kStringAdd), 2));
     }
     if_sameencodingandsequential.End();
   }
@@ -5299,8 +5294,7 @@ void HOptimizedGraphBuilder::BuildForInBody(ForInStatement* stmt,
     map = graph()->GetConstant1();
     Runtime::FunctionId function_id = Runtime::kGetPropertyNamesFast;
     Add<HPushArguments>(enumerable);
-    array = Add<HCallRuntime>(isolate()->factory()->empty_string(),
-                              Runtime::FunctionForId(function_id), 1);
+    array = Add<HCallRuntime>(Runtime::FunctionForId(function_id), 1);
     Push(array);
     Add<HSimulate>(stmt->EnumId());
     Drop(1);
@@ -5355,8 +5349,7 @@ void HOptimizedGraphBuilder::BuildForInBody(ForInStatement* stmt,
   } else {
     Add<HPushArguments>(enumerable, key);
     Runtime::FunctionId function_id = Runtime::kForInFilter;
-    key = Add<HCallRuntime>(isolate()->factory()->empty_string(),
-                            Runtime::FunctionForId(function_id), 2);
+    key = Add<HCallRuntime>(Runtime::FunctionForId(function_id), 2);
     Push(key);
     Add<HSimulate>(stmt->FilterId());
     key = Pop();
@@ -5840,9 +5833,7 @@ void HOptimizedGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) {
                         Add<HConstant>(flags));
 
     Runtime::FunctionId function_id = Runtime::kCreateObjectLiteral;
-    literal = Add<HCallRuntime>(isolate()->factory()->empty_string(),
-                                Runtime::FunctionForId(function_id),
-                                4);
+    literal = Add<HCallRuntime>(Runtime::FunctionForId(function_id), 4);
   }
 
   // The object is expected in the bailout environment during computation
@@ -6011,9 +6002,7 @@ void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) {
                         Add<HConstant>(flags));
 
     Runtime::FunctionId function_id = Runtime::kCreateArrayLiteral;
-    literal = Add<HCallRuntime>(isolate()->factory()->empty_string(),
-                                Runtime::FunctionForId(function_id),
-                                4);
+    literal = Add<HCallRuntime>(Runtime::FunctionForId(function_id), 4);
 
     // Register to deopt if the boilerplate ElementsKind changes.
     top_info()->dependencies()->AssumeTransitionStable(site);
@@ -6502,7 +6491,6 @@ HValue* HOptimizedGraphBuilder::BuildMonomorphicAccess(
     DCHECK(info->IsLoad());
     if (is_strong(function_language_mode())) {
       return New<HCallRuntime>(
-          isolate()->factory()->empty_string(),
           Runtime::FunctionForId(Runtime::kThrowStrongModeImplicitConversion),
           0);
     } else {
@@ -7158,8 +7146,7 @@ void HOptimizedGraphBuilder::VisitThrow(Throw* expr) {
   HValue* value = environment()->Pop();
   if (!top_info()->is_tracking_positions()) SetSourcePosition(expr->position());
   Add<HPushArguments>(value);
-  Add<HCallRuntime>(isolate()->factory()->empty_string(),
-                    Runtime::FunctionForId(Runtime::kThrow), 1);
+  Add<HCallRuntime>(Runtime::FunctionForId(Runtime::kThrow), 1);
   Add<HSimulate>(expr->id());
 
   // If the throw definitely exits the function, we can finish with a dummy
@@ -10285,7 +10272,7 @@ void HOptimizedGraphBuilder::GenerateTypedArrayInitialize(
       Push(byte_length);
       CHECK_ALIVE(VisitForValue(arguments->at(kInitializeArg)));
       PushArgumentsFromEnvironment(kArgsLength);
-      Add<HCallRuntime>(expr->name(), expr->function(), kArgsLength);
+      Add<HCallRuntime>(expr->function(), kArgsLength);
     }
   }
   byte_offset_smi.End();
@@ -10376,11 +10363,10 @@ void HOptimizedGraphBuilder::VisitCallRuntime(CallRuntime* expr) {
     FOR_EACH_HYDROGEN_INTRINSIC(CALL_INTRINSIC_GENERATOR)
 #undef CALL_INTRINSIC_GENERATOR
     default: {
-      Handle<String> name = expr->name();
       int argument_count = expr->arguments()->length();
       CHECK_ALIVE(VisitExpressions(expr->arguments()));
       PushArgumentsFromEnvironment(argument_count);
-      HCallRuntime* call = New<HCallRuntime>(name, function, argument_count);
+      HCallRuntime* call = New<HCallRuntime>(function, argument_count);
       return ast_context()->ReturnInstruction(call, expr->id());
     }
   }
@@ -10411,7 +10397,6 @@ void HOptimizedGraphBuilder::VisitDelete(UnaryOperation* expr) {
     HValue* obj = Pop();
     Add<HPushArguments>(obj, key);
     HInstruction* instr = New<HCallRuntime>(
-        isolate()->factory()->empty_string(),
         Runtime::FunctionForId(is_strict(function_language_mode())
                                    ? Runtime::kDeleteProperty_Strict
                                    : Runtime::kDeleteProperty_Sloppy),
@@ -11018,7 +11003,6 @@ HValue* HGraphBuilder::BuildBinaryOperation(
       if_builder.OrIf<HHasInstanceTypeAndBranch>(right, ODDBALL_TYPE);
       if_builder.Then();
       Add<HCallRuntime>(
-          isolate()->factory()->empty_string(),
           Runtime::FunctionForId(Runtime::kThrowStrongModeImplicitConversion),
           0);
       if (!graph()->info()->IsStub()) {
@@ -11116,7 +11100,8 @@ static bool IsClassOfTest(CompareOperation* expr) {
   Literal* literal = expr->right()->AsLiteral();
   if (literal == NULL) return false;
   if (!literal->value()->IsString()) return false;
-  if (!call->name()->IsOneByteEqualTo(STATIC_CHAR_VECTOR("_ClassOf"))) {
+  if (!call->is_jsruntime() &&
+      call->function()->function_id != Runtime::kInlineClassOf) {
     return false;
   }
   DCHECK(call->arguments()->length() == 1);
@@ -12820,8 +12805,8 @@ void HOptimizedGraphBuilder::GenerateGetPrototype(CallRuntime* call) {
     needs_runtime.Then();
     {
       Add<HPushArguments>(object);
-      Push(Add<HCallRuntime>(
-          call->name(), Runtime::FunctionForId(Runtime::kGetPrototype), 1));
+      Push(
+          Add<HCallRuntime>(Runtime::FunctionForId(Runtime::kGetPrototype), 1));
     }
 
     needs_runtime.Else();
index 3a53f873cc2f16a4ad503cb4be50d762a751a004..c45b313faff6df30717a3f5a3adb694a5603a413 100644 (file)
@@ -2003,10 +2003,9 @@ inline HInstruction* HGraphBuilder::AddUncasted<HReturn>(HConstant* value) {
 
 template<>
 inline HCallRuntime* HGraphBuilder::Add<HCallRuntime>(
-    Handle<String> name,
     const Runtime::Function* c_function,
     int argument_count) {
-  HCallRuntime* instr = New<HCallRuntime>(name, c_function, argument_count);
+  HCallRuntime* instr = New<HCallRuntime>(c_function, argument_count);
   if (graph()->info()->IsStub()) {
     // When compiling code stubs, we don't want to save all double registers
     // upon entry to the stub, but instead have the call runtime instruction
@@ -2023,7 +2022,7 @@ inline HInstruction* HGraphBuilder::AddUncasted<HCallRuntime>(
     Handle<String> name,
     const Runtime::Function* c_function,
     int argument_count) {
-  return Add<HCallRuntime>(name, c_function, argument_count);
+  return Add<HCallRuntime>(c_function, argument_count);
 }
 
 
index 3bc52cbbf5dbedd475e1c2069b2e474454b8cdda..8d046ee95536d1c47164afd10bf2871094454589 100644 (file)
@@ -252,8 +252,6 @@ function JsonSerializeAdapter(key, object) {
   return JSONSerialize(key, holder, UNDEFINED, new InternalArray(), "", "");
 }
 
-utils.ExportToRuntime(function(to) {
-  to["json_serialize_adapter"] = JsonSerializeAdapter;
-});
+%InstallToContext(["json_serialize_adapter", JsonSerializeAdapter]);
 
 })
index a0176d34a24c0b1aa449dc5f35f62fd8f19317ae..b930a38b4c4bc24ef8b96cbc59c3179ae4d202b7 100644 (file)
@@ -1025,22 +1025,24 @@ captureStackTrace = function captureStackTrace(obj, cons_opt) {
 
 GlobalError.captureStackTrace = captureStackTrace;
 
-utils.ExportToRuntime(function(to) {
-  to["error_function"] = GlobalError;
-  to["eval_error_function"] = GlobalEvalError;
-  to["get_stack_trace_line_fun"] = GetStackTraceLine;
-  to["make_error_function"] = MakeGenericError;
-  to["message_get_column_number"] = GetColumnNumber;
-  to["message_get_line_number"] = GetLineNumber;
-  to["message_get_source_line"] = GetSourceLine;
-  to["no_side_effect_to_string_fun"] = NoSideEffectToString;
-  to["range_error_function"] = GlobalRangeError;
-  to["reference_error_function"] = GlobalReferenceError;
-  to["stack_overflow_boilerplate"] = StackOverflowBoilerplate;
-  to["syntax_error_function"] = GlobalSyntaxError;
-  to["to_detail_string_fun"] = ToDetailString;
-  to["type_error_function"] = GlobalTypeError;
-  to["uri_error_function"] = GlobalURIError;
-});
+%InstallToContext([
+  "error_function", GlobalError,
+  "eval_error_function", GlobalEvalError,
+  "get_stack_trace_line_fun", GetStackTraceLine,
+  "make_error_function", MakeGenericError,
+  "make_range_error", MakeRangeError,
+  "make_type_error", MakeTypeError,
+  "message_get_column_number", GetColumnNumber,
+  "message_get_line_number", GetLineNumber,
+  "message_get_source_line", GetSourceLine,
+  "no_side_effect_to_string_fun", NoSideEffectToString,
+  "range_error_function", GlobalRangeError,
+  "reference_error_function", GlobalReferenceError,
+  "stack_overflow_boilerplate", StackOverflowBoilerplate,
+  "syntax_error_function", GlobalSyntaxError,
+  "to_detail_string_fun", ToDetailString,
+  "type_error_function", GlobalTypeError,
+  "uri_error_function", GlobalURIError,
+]);
 
 });
index 243e093244eb3378a5d4ca586b2b4c0597eeffdb..0f1f6d37fbadab8acd1b12968fed89e70a93f62c 100644 (file)
@@ -703,15 +703,14 @@ $observeEnqueueSpliceRecord = EnqueueSpliceRecord;
 $observeBeginPerformSplice = BeginPerformSplice;
 $observeEndPerformSplice = EndPerformSplice;
 
-utils.ExportToRuntime(function(to) {
-  to["native_object_get_notifier"] = NativeObjectGetNotifier;
-  to["native_object_notifier_perform_change"] =
-      NativeObjectNotifierPerformChange;
-  to["native_object_observe"] = NativeObjectObserve;
-  to["observers_begin_perform_splice"] = BeginPerformSplice;
-  to["observers_end_perform_splice"] = EndPerformSplice;
-  to["observers_enqueue_splice"] = EnqueueSpliceRecord;
-  to["observers_notify_change"] = NotifyChange;
-});
+%InstallToContext([
+  "native_object_get_notifier", NativeObjectGetNotifier,
+  "native_object_notifier_perform_change", NativeObjectNotifierPerformChange,
+  "native_object_observe", NativeObjectObserve,
+  "observers_begin_perform_splice", BeginPerformSplice,
+  "observers_end_perform_splice", EndPerformSplice,
+  "observers_enqueue_splice", EnqueueSpliceRecord,
+  "observers_notify_change", NotifyChange,
+]);
 
 })
index 5faca42f3b4e8c774ce9f4a3b39238e4e8bc757f..2e6e0ad1cfab6aebc322c3cf930eb178fb370ec1 100644 (file)
@@ -371,9 +371,7 @@ FunctionLiteral* Parser::DefaultConstructor(bool call_super, Scope* scope,
           Variable::NORMAL, pos);
       args->Add(this_function_proxy, zone());
       CallRuntime* call = factory()->NewCallRuntime(
-          ast_value_factory()->empty_string(),
-          Runtime::FunctionForId(Runtime::kInlineDefaultConstructorCallSuper),
-          args, pos);
+          Runtime::kInlineDefaultConstructorCallSuper, args, pos);
       body->Add(factory()->NewReturnStatement(call, pos), zone());
     }
 
@@ -671,9 +669,8 @@ Expression* ParserTraits::NewThrowError(Runtime::FunctionId id,
   ZoneList<Expression*>* args = new (zone) ZoneList<Expression*>(2, zone);
   args->Add(parser_->factory()->NewSmiLiteral(message, pos), zone);
   args->Add(parser_->factory()->NewStringLiteral(arg, pos), zone);
-  CallRuntime* call_constructor = parser_->factory()->NewCallRuntime(
-      parser_->ast_value_factory()->empty_string(), Runtime::FunctionForId(id),
-      args, pos);
+  CallRuntime* call_constructor =
+      parser_->factory()->NewCallRuntime(id, args, pos);
   return parser_->factory()->NewThrow(call_constructor, pos);
 }
 
@@ -2855,9 +2852,7 @@ Statement* Parser::ParseReturnStatement(bool* ok) {
           new (zone()) ZoneList<Expression*>(1, zone());
       is_spec_object_args->Add(factory()->NewVariableProxy(temp), zone());
       Expression* is_spec_object_call = factory()->NewCallRuntime(
-          ast_value_factory()->is_spec_object_string(),
-          Runtime::FunctionForId(Runtime::kInlineIsSpecObject),
-          is_spec_object_args, pos);
+          Runtime::kInlineIsSpecObject, is_spec_object_args, pos);
 
       // %_IsSpecObject(temp) ? temp : throw_expression
       Expression* is_object_conditional = factory()->NewConditional(
@@ -3208,9 +3203,7 @@ Expression* Parser::BuildIteratorNextResult(Expression* iterator,
       new (zone()) ZoneList<Expression*>(1, zone());
   is_spec_object_args->Add(left, zone());
   Expression* is_spec_object_call = factory()->NewCallRuntime(
-      ast_value_factory()->is_spec_object_string(),
-      Runtime::FunctionForId(Runtime::kInlineIsSpecObject), is_spec_object_args,
-      pos);
+      Runtime::kInlineIsSpecObject, is_spec_object_args, pos);
 
   // %ThrowIteratorResultNotAnObject(result)
   Expression* result_proxy_again = factory()->NewVariableProxy(result);
@@ -3218,9 +3211,7 @@ Expression* Parser::BuildIteratorNextResult(Expression* iterator,
       new (zone()) ZoneList<Expression*>(1, zone());
   throw_arguments->Add(result_proxy_again, zone());
   Expression* throw_call = factory()->NewCallRuntime(
-      ast_value_factory()->throw_iterator_result_not_an_object_string(),
-      Runtime::FunctionForId(Runtime::kThrowIteratorResultNotAnObject),
-      throw_arguments, pos);
+      Runtime::kThrowIteratorResultNotAnObject, throw_arguments, pos);
 
   return factory()->NewBinaryOperation(
       Token::AND,
@@ -4322,12 +4313,9 @@ void Parser::AddAssertIsConstruct(ZoneList<Statement*>* body, int pos) {
   ZoneList<Expression*>* arguments =
       new (zone()) ZoneList<Expression*>(0, zone());
   CallRuntime* construct_check = factory()->NewCallRuntime(
-      ast_value_factory()->is_construct_call_string(),
-      Runtime::FunctionForId(Runtime::kInlineIsConstructCall), arguments, pos);
+      Runtime::kInlineIsConstructCall, arguments, pos);
   CallRuntime* non_callable_error = factory()->NewCallRuntime(
-      ast_value_factory()->empty_string(),
-      Runtime::FunctionForId(Runtime::kThrowConstructorNonCallableError),
-      arguments, pos);
+      Runtime::kThrowConstructorNonCallableError, arguments, pos);
   IfStatement* if_statement = factory()->NewIfStatement(
       factory()->NewUnaryOperation(Token::NOT, construct_check, pos),
       factory()->NewReturnStatement(non_callable_error, pos),
@@ -4479,9 +4467,7 @@ ZoneList<Statement*>* Parser::ParseEagerFunctionBody(
       ZoneList<Expression*>* arguments =
           new(zone()) ZoneList<Expression*>(0, zone());
       CallRuntime* allocation = factory()->NewCallRuntime(
-          ast_value_factory()->empty_string(),
-          Runtime::FunctionForId(Runtime::kCreateJSGeneratorObject), arguments,
-          pos);
+          Runtime::kCreateJSGeneratorObject, arguments, pos);
       VariableProxy* init_proxy = factory()->NewVariableProxy(
           function_state_->generator_object_variable());
       Assignment* assignment = factory()->NewAssignment(
@@ -4739,40 +4725,42 @@ Expression* Parser::ParseV8Intrinsic(bool* ok) {
 
   const Runtime::Function* function = Runtime::FunctionForName(name->string());
 
-  // Check for built-in IS_VAR macro.
-  if (function != NULL &&
-      function->intrinsic_type == Runtime::RUNTIME &&
-      function->function_id == Runtime::kIS_VAR) {
-    // %IS_VAR(x) evaluates to x if x is a variable,
-    // leads to a parse error otherwise.  Could be implemented as an
-    // inline function %_IS_VAR(x) to eliminate this special case.
-    if (args->length() == 1 && args->at(0)->AsVariableProxy() != NULL) {
-      return args->at(0);
-    } else {
-      ReportMessage(MessageTemplate::kNotIsvar);
+  if (function != NULL) {
+    // Check for built-in IS_VAR macro.
+    if (function->function_id == Runtime::kIS_VAR) {
+      DCHECK_EQ(Runtime::RUNTIME, function->intrinsic_type);
+      // %IS_VAR(x) evaluates to x if x is a variable,
+      // leads to a parse error otherwise.  Could be implemented as an
+      // inline function %_IS_VAR(x) to eliminate this special case.
+      if (args->length() == 1 && args->at(0)->AsVariableProxy() != NULL) {
+        return args->at(0);
+      } else {
+        ReportMessage(MessageTemplate::kNotIsvar);
+        *ok = false;
+        return NULL;
+      }
+    }
+
+    // Check that the expected number of arguments are being passed.
+    if (function->nargs != -1 && function->nargs != args->length()) {
+      ReportMessage(MessageTemplate::kIllegalAccess);
       *ok = false;
       return NULL;
     }
-  }
 
-  // Check that the expected number of arguments are being passed.
-  if (function != NULL &&
-      function->nargs != -1 &&
-      function->nargs != args->length()) {
-    ReportMessage(MessageTemplate::kIllegalAccess);
-    *ok = false;
-    return NULL;
+    return factory()->NewCallRuntime(function, args, pos);
   }
 
-  // Check that the function is defined if it's an inline runtime call.
-  if (function == NULL && name->FirstCharacter() == '_') {
+  int context_index = Context::IntrinsicIndexForName(name->string());
+
+  // Check that the function is defined.
+  if (context_index == Context::kNotFound) {
     ParserTraits::ReportMessage(MessageTemplate::kNotDefined, name);
     *ok = false;
     return NULL;
   }
 
-  // We have a valid intrinsics call or a call to a builtin.
-  return factory()->NewCallRuntime(name, function, args, pos);
+  return factory()->NewCallRuntime(context_index, args, pos);
 }
 
 
@@ -5915,8 +5903,7 @@ Expression* Parser::CloseTemplateLiteral(TemplateLiteralState* state, int start,
           new (zone()) ZoneList<Expression*>(1, zone());
       args->Add(sub, zone());
       Expression* middle = factory()->NewCallRuntime(
-          ast_value_factory()->to_string_string(), NULL, args,
-          sub->position());
+          Context::TO_STRING_FUN_INDEX, args, sub->position());
 
       expr = factory()->NewBinaryOperation(
           Token::ADD, factory()->NewBinaryOperation(
@@ -5948,7 +5935,7 @@ Expression* Parser::CloseTemplateLiteral(TemplateLiteralState* state, int start,
 
     this->CheckPossibleEvalCall(tag, scope_);
     Expression* call_site = factory()->NewCallRuntime(
-        ast_value_factory()->get_template_callsite_string(), NULL, args, start);
+        Context::GET_TEMPLATE_CALL_SITE_INDEX, args, start);
 
     // Call TagFn
     ZoneList<Expression*>* call_args =
@@ -6004,10 +5991,9 @@ ZoneList<v8::internal::Expression*>* Parser::PrepareSpreadArguments(
     ZoneList<Expression*>* spread_list =
         new (zone()) ZoneList<Expression*>(0, zone());
     spread_list->Add(list->at(0)->AsSpread()->expression(), zone());
-    args->Add(
-        factory()->NewCallRuntime(ast_value_factory()->spread_iterable_string(),
-                                  NULL, spread_list, RelocInfo::kNoPosition),
-        zone());
+    args->Add(factory()->NewCallRuntime(Context::SPREAD_ITERABLE_INDEX,
+                                        spread_list, RelocInfo::kNoPosition),
+              zone());
     return args;
   } else {
     // Spread-call with multiple arguments produces array literals for each
@@ -6041,16 +6027,14 @@ ZoneList<v8::internal::Expression*>* Parser::PrepareSpreadArguments(
       ZoneList<v8::internal::Expression*>* spread_list =
           new (zone()) ZoneList<v8::internal::Expression*>(1, zone());
       spread_list->Add(list->at(i++)->AsSpread()->expression(), zone());
-      args->Add(factory()->NewCallRuntime(
-                    ast_value_factory()->spread_iterable_string(), NULL,
-                    spread_list, RelocInfo::kNoPosition),
+      args->Add(factory()->NewCallRuntime(Context::SPREAD_ITERABLE_INDEX,
+                                          spread_list, RelocInfo::kNoPosition),
                 zone());
     }
 
     list = new (zone()) ZoneList<v8::internal::Expression*>(1, zone());
-    list->Add(factory()->NewCallRuntime(
-                  ast_value_factory()->spread_arguments_string(), NULL, args,
-                  RelocInfo::kNoPosition),
+    list->Add(factory()->NewCallRuntime(Context::SPREAD_ARGUMENTS_INDEX, args,
+                                        RelocInfo::kNoPosition),
               zone());
     return list;
   }
@@ -6066,13 +6050,12 @@ Expression* Parser::SpreadCall(Expression* function,
     // %ReflectConstruct(%GetPrototype(<this-function>), args, new.target))
     ZoneList<Expression*>* tmp = new (zone()) ZoneList<Expression*>(1, zone());
     tmp->Add(function->AsSuperCallReference()->this_function_var(), zone());
-    Expression* get_prototype = factory()->NewCallRuntime(
-        ast_value_factory()->empty_string(),
-        Runtime::FunctionForId(Runtime::kGetPrototype), tmp, pos);
+    Expression* get_prototype =
+        factory()->NewCallRuntime(Runtime::kGetPrototype, tmp, pos);
     args->InsertAt(0, get_prototype, zone());
     args->Add(function->AsSuperCallReference()->new_target_var(), zone());
-    return factory()->NewCallRuntime(
-        ast_value_factory()->reflect_construct_string(), NULL, args, pos);
+    return factory()->NewCallRuntime(Context::REFLECT_CONSTRUCT_INDEX, args,
+                                     pos);
   } else {
     if (function->IsProperty()) {
       // Method calls
@@ -6100,8 +6083,7 @@ Expression* Parser::SpreadCall(Expression* function,
       args->InsertAt(1, factory()->NewUndefinedLiteral(RelocInfo::kNoPosition),
                      zone());
     }
-    return factory()->NewCallRuntime(
-        ast_value_factory()->reflect_apply_string(), NULL, args, pos);
+    return factory()->NewCallRuntime(Context::REFLECT_APPLY_INDEX, args, pos);
   }
 }
 
@@ -6111,8 +6093,7 @@ Expression* Parser::SpreadCallNew(Expression* function,
                                   int pos) {
   args->InsertAt(0, function, zone());
 
-  return factory()->NewCallRuntime(
-      ast_value_factory()->reflect_construct_string(), NULL, args, pos);
+  return factory()->NewCallRuntime(Context::REFLECT_CONSTRUCT_INDEX, args, pos);
 }
 }  // namespace internal
 }  // namespace v8
index 489530d47750bafe3a520d6faf37ab494163e2ea..f7e5b434664ce5905effdbee891e44859ae77aea 100644 (file)
@@ -142,10 +142,9 @@ void Parser::PatternRewriter::VisitVariableProxy(VariableProxy* pattern) {
       // and add it to the initialization statement block.
       // Note that the function does different things depending on
       // the number of arguments (1 or 2).
-      initialize = factory()->NewCallRuntime(
-          ast_value_factory()->initialize_const_global_string(),
-          Runtime::FunctionForId(Runtime::kInitializeConstGlobal), arguments,
-          descriptor_->initialization_pos);
+      initialize =
+          factory()->NewCallRuntime(Runtime::kInitializeConstGlobal, arguments,
+                                    descriptor_->initialization_pos);
     } else {
       // Add language mode.
       // We may want to pass singleton to avoid Literal allocations.
@@ -163,10 +162,9 @@ void Parser::PatternRewriter::VisitVariableProxy(VariableProxy* pattern) {
         value = NULL;  // zap the value to avoid the unnecessary assignment
         // Construct the call to Runtime_InitializeVarGlobal
         // and add it to the initialization statement block.
-        initialize = factory()->NewCallRuntime(
-            ast_value_factory()->initialize_var_global_string(),
-            Runtime::FunctionForId(Runtime::kInitializeVarGlobal), arguments,
-            descriptor_->declaration_pos);
+        initialize =
+            factory()->NewCallRuntime(Runtime::kInitializeVarGlobal, arguments,
+                                      descriptor_->declaration_pos);
       } else {
         initialize = NULL;
       }
@@ -312,7 +310,7 @@ void Parser::PatternRewriter::VisitArrayLiteral(ArrayLiteral* node) {
 
   if (spread != nullptr) {
     // array = [];
-    // if (!done) $concatIterableToArray(array, iterator);
+    // if (!done) %concat_iterable_to_array(array, iterator);
     auto empty_exprs = new (zone()) ZoneList<Expression*>(0, zone());
     auto array = CreateTempVar(factory()->NewArrayLiteral(
         empty_exprs,
@@ -324,9 +322,9 @@ void Parser::PatternRewriter::VisitArrayLiteral(ArrayLiteral* node) {
     auto arguments = new (zone()) ZoneList<Expression*>(2, zone());
     arguments->Add(factory()->NewVariableProxy(array), zone());
     arguments->Add(factory()->NewVariableProxy(iterator), zone());
-    auto spread_into_array_call = factory()->NewCallRuntime(
-        ast_value_factory()->concat_iterable_to_array_string(), nullptr,
-        arguments, RelocInfo::kNoPosition);
+    auto spread_into_array_call =
+        factory()->NewCallRuntime(Context::CONCAT_ITERABLE_TO_ARRAY_INDEX,
+                                  arguments, RelocInfo::kNoPosition);
 
     auto if_statement = factory()->NewIfStatement(
         factory()->NewUnaryOperation(Token::NOT,
index bf28cc6378749a94217a0949bd04da43a01fc11b..c5ac881be298805f18baa9bc40f498492b327e2f 100644 (file)
@@ -800,8 +800,7 @@ void PrettyPrinter::VisitCallNew(CallNew* node) {
 
 
 void PrettyPrinter::VisitCallRuntime(CallRuntime* node) {
-  Print("%%");
-  PrintLiteral(node->name(), false);
+  Print("%%%s\n", node->debug_name());
   PrintArguments(node->arguments());
 }
 
@@ -1533,9 +1532,8 @@ void AstPrinter::VisitCallNew(CallNew* node) {
 
 void AstPrinter::VisitCallRuntime(CallRuntime* node) {
   EmbeddedVector<char, 128> buf;
-  FormatICSlotNode(&buf, node, "CALL RUNTIME", node->CallRuntimeFeedbackSlot());
   IndentedScope indent(this, buf.start());
-  PrintLiteralIndented("NAME", node->name(), false);
+  Print("NAME %s\n", node->debug_name());
   PrintArguments(node->arguments());
 }
 
index 56f9ed5b38fa576f0a2c563877e37114d1b9ab8e..5a0832c25ba682273a6b00babaedf05a6f35f31c 100644 (file)
@@ -13,7 +13,6 @@
 
 var imports = UNDEFINED;
 var imports_from_experimental = UNDEFINED;
-var exports_to_runtime = UNDEFINED;
 var exports_container = {};
 
 // Export to other scripts.
@@ -25,13 +24,6 @@ function Export(f) {
 }
 
 
-// Export to the native context for calls from the runtime.
-function ExportToRuntime(f) {
-  f.next = exports_to_runtime;
-  exports_to_runtime = f;
-}
-
-
 // Import from other scripts. The actual importing happens in PostNatives and
 // PostExperimental so that we can import from scripts executed later. However,
 // that means that the import is not available until the very end. If the
@@ -173,13 +165,6 @@ function PostNatives(utils) {
     imports(exports_container);
   }
 
-  var runtime_container = {};
-  for ( ; !IS_UNDEFINED(exports_to_runtime);
-          exports_to_runtime = exports_to_runtime.next) {
-    exports_to_runtime(runtime_container);
-  }
-  %ImportToRuntime(runtime_container);
-
   // Whitelist of exports from normal natives to experimental natives and debug.
   var expose_list = [
     "ArrayToString",
@@ -235,12 +220,6 @@ function PostExperimentals(utils) {
           imports_from_experimental = imports_from_experimental.next) {
     imports_from_experimental(exports_container);
   }
-  var runtime_container = {};
-  for ( ; !IS_UNDEFINED(exports_to_runtime);
-          exports_to_runtime = exports_to_runtime.next) {
-    exports_to_runtime(runtime_container);
-  }
-  %ImportExperimentalToRuntime(runtime_container);
 
   exports_container = UNDEFINED;
   private_symbols = UNDEFINED;
@@ -268,12 +247,11 @@ function PostDebug(utils) {
 
 // -----------------------------------------------------------------------
 
-%OptimizeObjectForAddingMultipleProperties(utils, 15);
+%OptimizeObjectForAddingMultipleProperties(utils, 14);
 
 utils.Import = Import;
 utils.ImportNow = ImportNow;
 utils.Export = Export;
-utils.ExportToRuntime = ExportToRuntime;
 utils.ImportFromExperimental = ImportFromExperimental;
 utils.GetPrivateSymbol = GetPrivateSymbol;
 utils.SetFunctionName = SetFunctionName;
index 31b6cc12468dcefefb51c89048f0a497e8f6283d..db1f36095d11c95fd5921e953a214d39c5f9aa30 100644 (file)
@@ -379,15 +379,14 @@ utils.InstallFunctions(GlobalPromise.prototype, DONT_ENUM, [
   "catch", PromiseCatch
 ]);
 
-utils.ExportToRuntime(function(to) {
-  to["promise_catch"] = PromiseCatch;
-  to["promise_chain"] = PromiseChain;
-  to["promise_create"] = PromiseCreate;
-  to["promise_has_user_defined_reject_handler"] =
-      PromiseHasUserDefinedRejectHandler;
-  to["promise_reject"] = PromiseReject;
-  to["promise_resolve"] = PromiseResolve;
-  to["promise_then"] = PromiseThen;
-});
+%InstallToContext([
+  "promise_catch", PromiseCatch,
+  "promise_chain", PromiseChain,
+  "promise_create", PromiseCreate,
+  "promise_has_user_defined_reject_handler", PromiseHasUserDefinedRejectHandler,
+  "promise_reject", PromiseReject,
+  "promise_resolve", PromiseResolve,
+  "promise_then", PromiseThen,
+]);
 
 })
index 6f18609400b793eab3356eb1fc72ce21fccfb380..c8ad42ff84aba88b8558406b4ecf1bf1101d22b6 100644 (file)
@@ -200,11 +200,11 @@ utils.Export(function(to) {
   to.ProxyDerivedKeysTrap = DerivedKeysTrap;
 });
 
-utils.ExportToRuntime(function(to) {
-  to["derived_get_trap"] = DerivedGetTrap;
-  to["derived_has_trap"] = DerivedHasTrap;
-  to["derived_set_trap"] = DerivedSetTrap;
-  to["proxy_enumerate"] = ProxyEnumerate;
-});
+%InstallToContext([
+  "derived_get_trap", DerivedGetTrap,
+  "derived_has_trap", DerivedHasTrap,
+  "derived_set_trap", DerivedSetTrap,
+  "proxy_enumerate", ProxyEnumerate,
+]);
 
 })
index e717b26158c0258c24d147034f337684ae4e8972..a6a543fe07fe1e42e637e1d53f89dd6cd229ede0 100644 (file)
@@ -15,6 +15,7 @@ var harmony_unicode_regexps = false;
 
 var GlobalRegExp = global.RegExp;
 var InternalPackedArray = utils.InternalPackedArray;
+var ToNumber;
 
 utils.Import(function(from) {
   ToNumber = from.ToNumber;
index 5da9c90682a75b807ee597775f91a53b664350cb..a7218058d7dd24108b769ce412c091dd4d81b542 100644 (file)
@@ -55,18 +55,18 @@ function EQUALS(y) {
         if (!IS_SPEC_OBJECT(y)) {
           if (IS_SYMBOL(y) || IS_SIMD_VALUE(y)) return 1;  // not equal
           // String or boolean.
-          return %NumberEquals(x, %$toNumber(y));
+          return %NumberEquals(x, %to_number_fun(y));
         }
-        y = %$toPrimitive(y, NO_HINT);
+        y = %to_primitive(y, NO_HINT);
       }
     } else if (IS_STRING(x)) {
       while (true) {
         if (IS_STRING(y)) return %StringEquals(x, y);
-        if (IS_NUMBER(y)) return %NumberEquals(%$toNumber(x), y);
-        if (IS_BOOLEAN(y)) return %NumberEquals(%$toNumber(x), %$toNumber(y));
+        if (IS_NUMBER(y)) return %NumberEquals(%to_number_fun(x), y);
+        if (IS_BOOLEAN(y)) return %NumberEquals(%to_number_fun(x), %to_number_fun(y));
         if (IS_NULL_OR_UNDEFINED(y)) return 1;  // not equal
         if (IS_SYMBOL(y) || IS_SIMD_VALUE(y)) return 1;  // not equal
-        y = %$toPrimitive(y, NO_HINT);
+        y = %to_primitive(y, NO_HINT);
       }
     } else if (IS_SYMBOL(x)) {
       if (IS_SYMBOL(y)) return %_ObjectEquals(x, y) ? 0 : 1;
@@ -74,12 +74,12 @@ function EQUALS(y) {
     } else if (IS_BOOLEAN(x)) {
       if (IS_BOOLEAN(y)) return %_ObjectEquals(x, y) ? 0 : 1;
       if (IS_NULL_OR_UNDEFINED(y)) return 1;
-      if (IS_NUMBER(y)) return %NumberEquals(%$toNumber(x), y);
-      if (IS_STRING(y)) return %NumberEquals(%$toNumber(x), %$toNumber(y));
+      if (IS_NUMBER(y)) return %NumberEquals(%to_number_fun(x), y);
+      if (IS_STRING(y)) return %NumberEquals(%to_number_fun(x), %to_number_fun(y));
       if (IS_SYMBOL(y) || IS_SIMD_VALUE(y)) return 1;  // not equal
       // y is object.
-      x = %$toNumber(x);
-      y = %$toPrimitive(y, NO_HINT);
+      x = %to_number_fun(x);
+      y = %to_primitive(y, NO_HINT);
     } else if (IS_NULL_OR_UNDEFINED(x)) {
       return IS_NULL_OR_UNDEFINED(y) ? 0 : 1;
     } else if (IS_SIMD_VALUE(x)) {
@@ -90,11 +90,11 @@ function EQUALS(y) {
       if (IS_SPEC_OBJECT(y)) return %_ObjectEquals(x, y) ? 0 : 1;
       if (IS_NULL_OR_UNDEFINED(y)) return 1;  // not equal
       if (IS_BOOLEAN(y)) {
-        y = %$toNumber(y);
+        y = %to_number_fun(y);
       } else if (IS_SYMBOL(y) || IS_SIMD_VALUE(y)) {
         return 1;  // not equal
       }
-      x = %$toPrimitive(x, NO_HINT);
+      x = %to_primitive(x, NO_HINT);
     }
   }
 }
@@ -116,22 +116,22 @@ function COMPARE(x, ncr) {
     left = this;
   } else if (IS_UNDEFINED(this)) {
     if (!IS_UNDEFINED(x)) {
-      %$toPrimitive(x, NUMBER_HINT);
+      %to_primitive(x, NUMBER_HINT);
     }
     return ncr;
   } else if (IS_UNDEFINED(x)) {
-    %$toPrimitive(this, NUMBER_HINT);
+    %to_primitive(this, NUMBER_HINT);
     return ncr;
   } else {
-    left = %$toPrimitive(this, NUMBER_HINT);
+    left = %to_primitive(this, NUMBER_HINT);
   }
 
-  right = %$toPrimitive(x, NUMBER_HINT);
+  right = %to_primitive(x, NUMBER_HINT);
   if (IS_STRING(left) && IS_STRING(right)) {
     return %_StringCompare(left, right);
   } else {
-    var left_number = %$toNumber(left);
-    var right_number = %$toNumber(right);
+    var left_number = %to_number_fun(left);
+    var right_number = %to_number_fun(right);
     if (NUMBER_IS_NAN(left_number) || NUMBER_IS_NAN(right_number)) return ncr;
     return %NumberCompare(left_number, right_number, ncr);
   }
@@ -142,7 +142,7 @@ function COMPARE_STRONG(x, ncr) {
   if (IS_STRING(this) && IS_STRING(x)) return %_StringCompare(this, x);
   if (IS_NUMBER(this) && IS_NUMBER(x)) return %NumberCompare(this, x, ncr);
 
-  throw %MakeTypeError(kStrongImplicitConversion);
+  throw %make_type_error(kStrongImplicitConversion);
 }
 
 
@@ -159,15 +159,15 @@ function ADD(x) {
   if (IS_STRING(this) && IS_STRING(x)) return %_StringAdd(this, x);
 
   // Default implementation.
-  var a = %$toPrimitive(this, NO_HINT);
-  var b = %$toPrimitive(x, NO_HINT);
+  var a = %to_primitive(this, NO_HINT);
+  var b = %to_primitive(x, NO_HINT);
 
   if (IS_STRING(a)) {
-    return %_StringAdd(a, %$toString(b));
+    return %_StringAdd(a, %to_string_fun(b));
   } else if (IS_STRING(b)) {
-    return %_StringAdd(%$nonStringToString(a), b);
+    return %_StringAdd(%non_string_to_string(a), b);
   } else {
-    return %NumberAdd(%$toNumber(a), %$toNumber(b));
+    return %NumberAdd(%to_number_fun(a), %to_number_fun(b));
   }
 }
 
@@ -177,7 +177,7 @@ function ADD_STRONG(x) {
   if (IS_NUMBER(this) && IS_NUMBER(x)) return %NumberAdd(this, x);
   if (IS_STRING(this) && IS_STRING(x)) return %_StringAdd(this, x);
 
-  throw %MakeTypeError(kStrongImplicitConversion);
+  throw %make_type_error(kStrongImplicitConversion);
 }
 
 
@@ -189,7 +189,7 @@ function STRING_ADD_LEFT(y) {
     } else {
       y = IS_NUMBER(y)
           ? %_NumberToString(y)
-          : %$toString(%$toPrimitive(y, NO_HINT));
+          : %to_string_fun(%to_primitive(y, NO_HINT));
     }
   }
   return %_StringAdd(this, y);
@@ -205,7 +205,7 @@ function STRING_ADD_RIGHT(y) {
     } else {
       x = IS_NUMBER(x)
           ? %_NumberToString(x)
-          : %$toString(%$toPrimitive(x, NO_HINT));
+          : %to_string_fun(%to_primitive(x, NO_HINT));
     }
   }
   return %_StringAdd(x, y);
@@ -214,8 +214,8 @@ function STRING_ADD_RIGHT(y) {
 
 // ECMA-262, section 11.6.2, page 50.
 function SUB(y) {
-  var x = IS_NUMBER(this) ? this : %$nonNumberToNumber(this);
-  if (!IS_NUMBER(y)) y = %$nonNumberToNumber(y);
+  var x = IS_NUMBER(this) ? this : %non_number_to_number(this);
+  if (!IS_NUMBER(y)) y = %non_number_to_number(y);
   return %NumberSub(x, y);
 }
 
@@ -225,14 +225,14 @@ function SUB_STRONG(y) {
   if (IS_NUMBER(this) && IS_NUMBER(y)) {
     return %NumberSub(this, y);
   }
-  throw %MakeTypeError(kStrongImplicitConversion);
+  throw %make_type_error(kStrongImplicitConversion);
 }
 
 
 // ECMA-262, section 11.5.1, page 48.
 function MUL(y) {
-  var x = IS_NUMBER(this) ? this : %$nonNumberToNumber(this);
-  if (!IS_NUMBER(y)) y = %$nonNumberToNumber(y);
+  var x = IS_NUMBER(this) ? this : %non_number_to_number(this);
+  if (!IS_NUMBER(y)) y = %non_number_to_number(y);
   return %NumberMul(x, y);
 }
 
@@ -242,14 +242,14 @@ function MUL_STRONG(y) {
   if (IS_NUMBER(this) && IS_NUMBER(y)) {
     return %NumberMul(this, y);
   }
-  throw %MakeTypeError(kStrongImplicitConversion);
+  throw %make_type_error(kStrongImplicitConversion);
 }
 
 
 // ECMA-262, section 11.5.2, page 49.
 function DIV(y) {
-  var x = IS_NUMBER(this) ? this : %$nonNumberToNumber(this);
-  if (!IS_NUMBER(y)) y = %$nonNumberToNumber(y);
+  var x = IS_NUMBER(this) ? this : %non_number_to_number(this);
+  if (!IS_NUMBER(y)) y = %non_number_to_number(y);
   return %NumberDiv(x, y);
 }
 
@@ -259,14 +259,14 @@ function DIV_STRONG(y) {
   if (IS_NUMBER(this) && IS_NUMBER(y)) {
     return %NumberDiv(this, y);
   }
-  throw %MakeTypeError(kStrongImplicitConversion);
+  throw %make_type_error(kStrongImplicitConversion);
 }
 
 
 // ECMA-262, section 11.5.3, page 49.
 function MOD(y) {
-  var x = IS_NUMBER(this) ? this : %$nonNumberToNumber(this);
-  if (!IS_NUMBER(y)) y = %$nonNumberToNumber(y);
+  var x = IS_NUMBER(this) ? this : %non_number_to_number(this);
+  if (!IS_NUMBER(y)) y = %non_number_to_number(y);
   return %NumberMod(x, y);
 }
 
@@ -276,7 +276,7 @@ function MOD_STRONG(y) {
   if (IS_NUMBER(this) && IS_NUMBER(y)) {
     return %NumberMod(this, y);
   }
-  throw %MakeTypeError(kStrongImplicitConversion);
+  throw %make_type_error(kStrongImplicitConversion);
 }
 
 
@@ -287,8 +287,8 @@ function MOD_STRONG(y) {
 
 // ECMA-262, section 11.10, page 57.
 function BIT_OR(y) {
-  var x = IS_NUMBER(this) ? this : %$nonNumberToNumber(this);
-  if (!IS_NUMBER(y)) y = %$nonNumberToNumber(y);
+  var x = IS_NUMBER(this) ? this : %non_number_to_number(this);
+  if (!IS_NUMBER(y)) y = %non_number_to_number(y);
   return %NumberOr(x, y);
 }
 
@@ -298,7 +298,7 @@ function BIT_OR_STRONG(y) {
   if (IS_NUMBER(this) && IS_NUMBER(y)) {
     return %NumberOr(this, y);
   }
-  throw %MakeTypeError(kStrongImplicitConversion);
+  throw %make_type_error(kStrongImplicitConversion);
 }
 
 
@@ -307,14 +307,14 @@ function BIT_AND(y) {
   var x;
   if (IS_NUMBER(this)) {
     x = this;
-    if (!IS_NUMBER(y)) y = %$nonNumberToNumber(y);
+    if (!IS_NUMBER(y)) y = %non_number_to_number(y);
   } else {
-    x = %$nonNumberToNumber(this);
+    x = %non_number_to_number(this);
     // Make sure to convert the right operand to a number before
     // bailing out in the fast case, but after converting the
     // left operand. This ensures that valueOf methods on the right
     // operand are always executed.
-    if (!IS_NUMBER(y)) y = %$nonNumberToNumber(y);
+    if (!IS_NUMBER(y)) y = %non_number_to_number(y);
     // Optimize for the case where we end up AND'ing a value
     // that doesn't convert to a number. This is common in
     // certain benchmarks.
@@ -329,14 +329,14 @@ function BIT_AND_STRONG(y) {
   if (IS_NUMBER(this) && IS_NUMBER(y)) {
     return %NumberAnd(this, y);
   }
-  throw %MakeTypeError(kStrongImplicitConversion);
+  throw %make_type_error(kStrongImplicitConversion);
 }
 
 
 // ECMA-262, section 11.10, page 57.
 function BIT_XOR(y) {
-  var x = IS_NUMBER(this) ? this : %$nonNumberToNumber(this);
-  if (!IS_NUMBER(y)) y = %$nonNumberToNumber(y);
+  var x = IS_NUMBER(this) ? this : %non_number_to_number(this);
+  if (!IS_NUMBER(y)) y = %non_number_to_number(y);
   return %NumberXor(x, y);
 }
 
@@ -346,14 +346,14 @@ function BIT_XOR_STRONG(y) {
   if (IS_NUMBER(this) && IS_NUMBER(y)) {
     return %NumberXor(this, y);
   }
-  throw %MakeTypeError(kStrongImplicitConversion);
+  throw %make_type_error(kStrongImplicitConversion);
 }
 
 
 // ECMA-262, section 11.7.1, page 51.
 function SHL(y) {
-  var x = IS_NUMBER(this) ? this : %$nonNumberToNumber(this);
-  if (!IS_NUMBER(y)) y = %$nonNumberToNumber(y);
+  var x = IS_NUMBER(this) ? this : %non_number_to_number(this);
+  if (!IS_NUMBER(y)) y = %non_number_to_number(y);
   return %NumberShl(x, y);
 }
 
@@ -363,7 +363,7 @@ function SHL_STRONG(y) {
   if (IS_NUMBER(this) && IS_NUMBER(y)) {
     return %NumberShl(this, y);
   }
-  throw %MakeTypeError(kStrongImplicitConversion);
+  throw %make_type_error(kStrongImplicitConversion);
 }
 
 
@@ -372,14 +372,14 @@ function SAR(y) {
   var x;
   if (IS_NUMBER(this)) {
     x = this;
-    if (!IS_NUMBER(y)) y = %$nonNumberToNumber(y);
+    if (!IS_NUMBER(y)) y = %non_number_to_number(y);
   } else {
-    x = %$nonNumberToNumber(this);
+    x = %non_number_to_number(this);
     // Make sure to convert the right operand to a number before
     // bailing out in the fast case, but after converting the
     // left operand. This ensures that valueOf methods on the right
     // operand are always executed.
-    if (!IS_NUMBER(y)) y = %$nonNumberToNumber(y);
+    if (!IS_NUMBER(y)) y = %non_number_to_number(y);
     // Optimize for the case where we end up shifting a value
     // that doesn't convert to a number. This is common in
     // certain benchmarks.
@@ -394,14 +394,14 @@ function SAR_STRONG(y) {
   if (IS_NUMBER(this) && IS_NUMBER(y)) {
     return %NumberSar(this, y);
   }
-  throw %MakeTypeError(kStrongImplicitConversion);
+  throw %make_type_error(kStrongImplicitConversion);
 }
 
 
 // ECMA-262, section 11.7.3, page 52.
 function SHR(y) {
-  var x = IS_NUMBER(this) ? this : %$nonNumberToNumber(this);
-  if (!IS_NUMBER(y)) y = %$nonNumberToNumber(y);
+  var x = IS_NUMBER(this) ? this : %non_number_to_number(this);
+  if (!IS_NUMBER(y)) y = %non_number_to_number(y);
   return %NumberShr(x, y);
 }
 
@@ -411,7 +411,7 @@ function SHR_STRONG(y) {
   if (IS_NUMBER(this) && IS_NUMBER(y)) {
     return %NumberShr(this, y);
   }
-  throw %MakeTypeError(kStrongImplicitConversion);
+  throw %make_type_error(kStrongImplicitConversion);
 }
 
 
@@ -423,7 +423,7 @@ function SHR_STRONG(y) {
 // ECMA-262, section 11.8.7, page 54.
 function IN(x) {
   if (!IS_SPEC_OBJECT(x)) {
-    throw %MakeTypeError(kInvalidInOperatorUse, this, x);
+    throw %make_type_error(kInvalidInOperatorUse, this, x);
   }
   if (%_IsNonNegativeSmi(this)) {
     if (IS_ARRAY(x) && %_HasFastPackedElements(x)) {
@@ -431,7 +431,7 @@ function IN(x) {
     }
     return %HasElement(x, this);
   }
-  return %HasProperty(x, %$toName(this));
+  return %HasProperty(x, %to_name(this));
 }
 
 
@@ -440,7 +440,7 @@ function CALL_NON_FUNCTION() {
   if (!IS_FUNCTION(delegate)) {
     var callsite = %RenderCallSite();
     if (callsite == "") callsite = typeof this;
-    throw %MakeTypeError(kCalledNonCallable, callsite);
+    throw %make_type_error(kCalledNonCallable, callsite);
   }
   return %Apply(delegate, this, arguments, 0, %_ArgumentsLength());
 }
@@ -451,7 +451,7 @@ function CALL_NON_FUNCTION_AS_CONSTRUCTOR() {
   if (!IS_FUNCTION(delegate)) {
     var callsite = %RenderCallSite();
     if (callsite == "") callsite = typeof this;
-    throw %MakeTypeError(kCalledNonCallable, callsite);
+    throw %make_type_error(kCalledNonCallable, callsite);
   }
   return %Apply(delegate, this, arguments, 0, %_ArgumentsLength());
 }
@@ -490,15 +490,15 @@ function APPLY_PREPARE(args) {
   // We can handle any number of apply arguments if the stack is
   // big enough, but sanity check the value to avoid overflow when
   // multiplying with pointer size.
-  if (length > kSafeArgumentsLength) throw %MakeRangeError(kStackOverflow);
+  if (length > kSafeArgumentsLength) throw %make_range_error(kStackOverflow);
 
   if (!IS_SPEC_FUNCTION(this)) {
-    throw %MakeTypeError(kApplyNonFunction, %$toString(this), typeof this);
+    throw %make_type_error(kApplyNonFunction, %to_string_fun(this), typeof this);
   }
 
   // Make sure the arguments list has the right type.
   if (args != null && !IS_SPEC_OBJECT(args)) {
-    throw %MakeTypeError(kWrongArgs, "Function.prototype.apply");
+    throw %make_type_error(kWrongArgs, "Function.prototype.apply");
   }
 
   // Return the length which is the number of arguments to copy to the
@@ -521,19 +521,19 @@ function REFLECT_APPLY_PREPARE(args) {
   }
 
   if (!IS_SPEC_FUNCTION(this)) {
-    throw %MakeTypeError(kCalledNonCallable, %$toString(this));
+    throw %make_type_error(kCalledNonCallable, %to_string_fun(this));
   }
 
   if (!IS_SPEC_OBJECT(args)) {
-    throw %MakeTypeError(kWrongArgs, "Reflect.apply");
+    throw %make_type_error(kWrongArgs, "Reflect.apply");
   }
 
-  length = %$toLength(args.length);
+  length = %to_length_fun(args.length);
 
   // We can handle any number of apply arguments if the stack is
   // big enough, but sanity check the value to avoid overflow when
   // multiplying with pointer size.
-  if (length > kSafeArgumentsLength) throw %MakeRangeError(kStackOverflow);
+  if (length > kSafeArgumentsLength) throw %make_range_error(kStackOverflow);
 
   // Return the length which is the number of arguments to copy to the
   // stack. It is guaranteed to be a small integer at this point.
@@ -560,30 +560,30 @@ function REFLECT_CONSTRUCT_PREPARE(
 
   if (!ctorOk) {
     if (!IS_SPEC_FUNCTION(this)) {
-      throw %MakeTypeError(kCalledNonCallable, %$toString(this));
+      throw %make_type_error(kCalledNonCallable, %to_string_fun(this));
     } else {
-      throw %MakeTypeError(kNotConstructor, %$toString(this));
+      throw %make_type_error(kNotConstructor, %to_string_fun(this));
     }
   }
 
   if (!newTargetOk) {
     if (!IS_SPEC_FUNCTION(newTarget)) {
-      throw %MakeTypeError(kCalledNonCallable, %$toString(newTarget));
+      throw %make_type_error(kCalledNonCallable, %to_string_fun(newTarget));
     } else {
-      throw %MakeTypeError(kNotConstructor, %$toString(newTarget));
+      throw %make_type_error(kNotConstructor, %to_string_fun(newTarget));
     }
   }
 
   if (!IS_SPEC_OBJECT(args)) {
-    throw %MakeTypeError(kWrongArgs, "Reflect.construct");
+    throw %make_type_error(kWrongArgs, "Reflect.construct");
   }
 
-  length = %$toLength(args.length);
+  length = %to_length_fun(args.length);
 
   // We can handle any number of apply arguments if the stack is
   // big enough, but sanity check the value to avoid overflow when
   // multiplying with pointer size.
-  if (length > kSafeArgumentsLength) throw %MakeRangeError(kStackOverflow);
+  if (length > kSafeArgumentsLength) throw %make_range_error(kStackOverflow);
 
   // Return the length which is the number of arguments to copy to the
   // stack. It is guaranteed to be a small integer at this point.
@@ -592,30 +592,30 @@ function REFLECT_CONSTRUCT_PREPARE(
 
 
 function CONCAT_ITERABLE_TO_ARRAY(iterable) {
-  return %$concatIterableToArray(this, iterable);
+  return %concat_iterable_to_array(this, iterable);
 };
 
 
 function STACK_OVERFLOW(length) {
-  throw %MakeRangeError(kStackOverflow);
+  throw %make_range_error(kStackOverflow);
 }
 
 
 // Convert the receiver to a number - forward to ToNumber.
 function TO_NUMBER() {
-  return %$toNumber(this);
+  return %to_number_fun(this);
 }
 
 
 // Convert the receiver to a string - forward to ToString.
 function TO_STRING() {
-  return %$toString(this);
+  return %to_string_fun(this);
 }
 
 
 // Convert the receiver to a string or symbol - forward to ToName.
 function TO_NAME() {
-  return %$toName(this);
+  return %to_name(this);
 }
 
 
@@ -822,7 +822,6 @@ function ToPositiveInteger(x, rangeErrorIndex) {
 // ----------------------------------------------------------------------------
 // Exports
 
-$concatIterableToArray = ConcatIterableToArray;
 $defaultNumber = DefaultNumber;
 $defaultString = DefaultString;
 $NaN = %GetRootNaN();
@@ -881,17 +880,25 @@ $toString = ToString;
   TO_NAME,
 });
 
-utils.ExportToRuntime(function(to) {
-  to["to_integer_fun"] = ToInteger;
-  to["to_length_fun"] = ToLength;
-  to["to_number_fun"] = ToNumber;
-  to["to_string_fun"] = ToString;
-});
+%InstallToContext([
+  "concat_iterable_to_array", ConcatIterableToArray,
+  "non_number_to_number", NonNumberToNumber,
+  "non_string_to_string", NonStringToString,
+  "to_integer_fun", ToInteger,
+  "to_length_fun", ToLength,
+  "to_name", ToName,
+  "to_number_fun", ToNumber,
+  "to_primitive", ToPrimitive,
+  "to_string_fun", ToString,
+]);
 
 utils.Export(function(to) {
   to.ToBoolean = ToBoolean;
+  to.ToLength = ToLength;
+  to.ToName = ToName;
   to.ToNumber = ToNumber;
+  to.ToPrimitive = ToPrimitive;
   to.ToString = ToString;
-})
+});
 
 })
index 12864066c4e333d3f9c7f7bb84b1164474a77171..236a79c7919a9dbe038a30ad6037758b04e67957 100644 (file)
@@ -37,22 +37,27 @@ RUNTIME_FUNCTION(Runtime_ExportPrivateSymbols) {
 }
 
 
-RUNTIME_FUNCTION(Runtime_ImportToRuntime) {
+RUNTIME_FUNCTION(Runtime_InstallToContext) {
   HandleScope scope(isolate);
   DCHECK(args.length() == 1);
-  CONVERT_ARG_HANDLE_CHECKED(JSObject, container, 0);
-  RUNTIME_ASSERT(isolate->bootstrapper()->IsActive());
-  Bootstrapper::ImportNatives(isolate, container);
-  return isolate->heap()->undefined_value();
-}
-
-
-RUNTIME_FUNCTION(Runtime_ImportExperimentalToRuntime) {
-  HandleScope scope(isolate);
-  DCHECK(args.length() == 1);
-  CONVERT_ARG_HANDLE_CHECKED(JSObject, container, 0);
+  CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0);
+  RUNTIME_ASSERT(array->HasFastElements());
   RUNTIME_ASSERT(isolate->bootstrapper()->IsActive());
-  Bootstrapper::ImportExperimentalNatives(isolate, container);
+  Handle<Context> native_context = isolate->native_context();
+  Handle<FixedArray> fixed_array(FixedArray::cast(array->elements()));
+  int length = Smi::cast(array->length())->value();
+  for (int i = 0; i < length; i += 2) {
+    RUNTIME_ASSERT(fixed_array->get(i)->IsString());
+    Handle<String> name(String::cast(fixed_array->get(i)));
+    RUNTIME_ASSERT(fixed_array->get(i + 1)->IsJSObject());
+    Handle<JSObject> object(JSObject::cast(fixed_array->get(i + 1)));
+    int index = Context::ImportedFieldIndexForName(name);
+    if (index == Context::kNotFound) {
+      index = Context::IntrinsicIndexForName(name);
+    }
+    RUNTIME_ASSERT(index != Context::kNotFound);
+    native_context->set(index, *object);
+  }
   return isolate->heap()->undefined_value();
 }
 
index 17ae043ae8e1e7470c54c8bc6768f071e9720da1..fa8f7a811a8d96c91eb2fa30e9627f278df0df34 100644 (file)
@@ -265,7 +265,7 @@ Object* DeclareLookupSlot(Isolate* isolate, Handle<String> name,
     if (is_var) return isolate->heap()->undefined_value();
 
     DCHECK(is_function);
-    if (index >= 0) {
+    if (index != Context::kNotFound) {
       DCHECK(holder.is_identical_to(context));
       context->set(index, *initial_value);
       return isolate->heap()->undefined_value();
@@ -346,7 +346,7 @@ RUNTIME_FUNCTION(Runtime_InitializeLegacyConstLookupSlot) {
     if (isolate->has_pending_exception()) return isolate->heap()->exception();
   }
 
-  if (index >= 0) {
+  if (index != Context::kNotFound) {
     DCHECK(holder->IsContext());
     // Property was found in a context.  Perform the assignment if the constant
     // was uninitialized.
@@ -950,8 +950,7 @@ static ObjectPair LoadLookupSlotHelper(Arguments args, Isolate* isolate,
     return MakePair(isolate->heap()->exception(), NULL);
   }
 
-  // If the index is non-negative, the slot has been found in a context.
-  if (index >= 0) {
+  if (index != Context::kNotFound) {
     DCHECK(holder->IsContext());
     // If the "property" we were looking for is a local variable, the
     // receiver is the global object; see ECMA-262, 3rd., 10.1.6 and 10.2.3.
@@ -1053,7 +1052,7 @@ RUNTIME_FUNCTION(Runtime_StoreLookupSlot) {
   }
 
   // The property was found in a context slot.
-  if (index >= 0) {
+  if (index != Context::kNotFound) {
     if ((binding_flags == MUTABLE_CHECK_INITIALIZED ||
          binding_flags == IMMUTABLE_CHECK_INITIALIZED_HARMONY) &&
         Handle<Context>::cast(holder)->is_the_hole(index)) {
index a490327af5266b5aac5e4cbe99a0f73cfa0a4797..15451c5c6e3828f356df456fe720d834ae633518 100644 (file)
@@ -4,6 +4,7 @@
 
 #include "src/runtime/runtime.h"
 
+#include "src/contexts.h"
 #include "src/handles-inl.h"
 #include "src/heap/heap.h"
 #include "src/isolate.h"
@@ -41,9 +42,10 @@ FOR_EACH_INTRINSIC_RETURN_PAIR(P)
   }                                                                \
   ,
 
-
 static const Runtime::Function kIntrinsicFunctions[] = {
-    FOR_EACH_INTRINSIC(F) FOR_EACH_INTRINSIC(I)};
+  FOR_EACH_INTRINSIC(F)
+  FOR_EACH_INTRINSIC(I)
+};
 
 #undef I
 #undef F
index 0ff2b62c5735bf925d2ceb53ececca34a7e33646..8258c8a42cf859618949bff7658615beb6a2d72f 100644 (file)
@@ -303,8 +303,7 @@ namespace internal {
 #define FOR_EACH_INTRINSIC_INTERNAL(F)        \
   F(CheckIsBootstrapping, 0, 1)               \
   F(ExportPrivateSymbols, 1, 1)               \
-  F(ImportToRuntime, 1, 1)                    \
-  F(ImportExperimentalToRuntime, 1, 1)        \
+  F(InstallToContext, 1, 1)                   \
   F(InstallJSBuiltins, 1, 1)                  \
   F(Throw, 1, 1)                              \
   F(ReThrow, 1, 1)                            \
@@ -1093,10 +1092,11 @@ class Runtime : public AllStatic {
   enum FunctionId {
 #define F(name, nargs, ressize) k##name,
 #define I(name, nargs, ressize) kInline##name,
-    FOR_EACH_INTRINSIC(F) FOR_EACH_INTRINSIC(I)
+  FOR_EACH_INTRINSIC(F)
+  FOR_EACH_INTRINSIC(I)
 #undef I
 #undef F
-        kNumFunctions,
+    kNumFunctions,
   };
 
   enum IntrinsicType { RUNTIME, INLINE };
@@ -1108,14 +1108,15 @@ class Runtime : public AllStatic {
     // The JS name of the function.
     const char* name;
 
-    // The C++ (native) entry point.  NULL if the function is inlined.
-    byte* entry;
+    // For RUNTIME functions, this is the C++ entry point.
+    // For INLINE functions this is the C++ entry point of the fall back.
+    Address entry;
 
     // The number of arguments expected. nargs is -1 if the function takes
     // a variable number of arguments.
-    int nargs;
+    int8_t nargs;
     // Size of result.  Most functions return a single pointer, size 1.
-    int result_size;
+    int8_t result_size;
   };
 
   static const int kNotFound = -1;
index b7e1527fc65746666f85c4230faadac12bef2dfc..b273bc39e816e1a828e891506564113b3ae526c3 100644 (file)
@@ -4,8 +4,6 @@
 
 // Called from a desugaring in the parser.
 
-var $getTemplateCallSite;
-
 (function(global, utils) {
 
 "use strict";
@@ -67,7 +65,7 @@ function SetCachedCallSite(siteObj, hash) {
 }
 
 
-$getTemplateCallSite = function(siteObj, rawStrings, hash) {
+function GetTemplateCallSite(siteObj, rawStrings, hash) {
   var cached = GetCachedCallSite(rawStrings, hash);
 
   if (!IS_UNDEFINED(cached)) return cached;
@@ -78,4 +76,9 @@ $getTemplateCallSite = function(siteObj, rawStrings, hash) {
   return SetCachedCallSite(%ObjectFreeze(siteObj), hash);
 }
 
+// ----------------------------------------------------------------------------
+// Exports
+
+%InstallToContext(["get_template_call_site", GetTemplateCallSite]);
+
 })
index 778607633382183a66cf2661303e3399513b04f0..7d8b78a6b2f4ee249510421725e05328a8de8159 100644 (file)
@@ -1809,11 +1809,11 @@ utils.Export(function(to) {
   to.ToNameArray = ToNameArray;
 });
 
-utils.ExportToRuntime(function(to) {
-  to["global_eval_fun"] = GlobalEval;
-  to["object_define_own_property"] = DefineOwnPropertyFromAPI;
-  to["object_get_own_property_descriptor"] = ObjectGetOwnPropertyDescriptor;
-  to["to_complete_property_descriptor"] = ToCompletePropertyDescriptor;
-});
+%InstallToContext([
+  "global_eval_fun", GlobalEval,
+  "object_define_own_property", DefineOwnPropertyFromAPI,
+  "object_get_own_property_descriptor", ObjectGetOwnPropertyDescriptor,
+  "to_complete_property_descriptor", ToCompletePropertyDescriptor,
+]);
 
 })
index 893c2fa46052eb9f64d3b1d00c8770b6a4e24a64..4ed83b318900db679cee862eaf81f06b97ffc37e 100644 (file)
@@ -144,7 +144,7 @@ TEST(RuntimeCallCPP2) {
 
 TEST(RuntimeCallJS) {
   FLAG_allow_natives_syntax = true;
-  FunctionTester T("(function(a) { return %$toString(a); })");
+  FunctionTester T("(function(a) { return %to_string_fun(a); })");
 
   T.CheckCall(T.Val("23"), T.Val(23), T.undefined());
   T.CheckCall(T.Val("4.2"), T.Val(4.2), T.undefined());
index 19ca85a13bd75649ee1d26297a73a0f4394e10bb..f3600951d4db46caf8d7400c78b3cdb35c92a69c 100644 (file)
@@ -2721,27 +2721,6 @@ TEST(NoErrorsRegexpLiteral) {
 }
 
 
-TEST(Intrinsics) {
-  const char* context_data[][2] = {
-    {"", ""},
-    { NULL, NULL }
-  };
-
-  const char* statement_data[] = {
-    "%someintrinsic(arg)",
-    NULL
-  };
-
-  // This test requires kAllowNatives to succeed.
-  static const ParserFlag always_true_flags[] = {
-    kAllowNatives
-  };
-
-  RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0,
-                    always_true_flags, 1);
-}
-
-
 TEST(NoErrorsNewExpression) {
   const char* context_data[][2] = {
     {"", ""},
index ab70abc1bbf46ca901e1ce8f30db0c23487b1e3e..2369763db77d32c5a08ada78557f26375a233508 100644 (file)
@@ -29,5 +29,4 @@
 
 // Test call of JS runtime functions.
 
-var a = %MakeError(0, "error");
-assertInstanceof(a, Error);
+assertEquals("1", %to_string_fun(1));