$arrayValues = ArrayValues;
-utils.ExportToRuntime(function(to) {
- to["array_values_iterator"] = ArrayValues;
-});
+%InstallToContext(["array_values_iterator", ArrayValues]);
})
: 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) {
#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") \
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") \
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_;
};
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,
}
-#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);
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(
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);
// 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),
// -----------------------------------------------------------------------
// 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,
+]);
})
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);
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) {
Handle<Context> context(this, isolate);
bool follow_context_chain = (flags & FOLLOW_CONTEXT_CHAIN) != 0;
- *index = -1;
+ *index = kNotFound;
*attributes = ABSENT;
*binding_flags = MISSING_BINDING;
}
+#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) {
// 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) \
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) \
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) \
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.
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()); \
}
static const int kSize = kHeaderSize + NATIVE_CONTEXT_SLOTS * kPointerSize;
+ static const int kNotFound = -1;
// GC support.
typedef FixedBodyDescriptor<
"toJSON", DateToJSON
]);
-utils.ExportToRuntime(function(to) {
- to["create_date_fun"] = CreateDate;
-});
+%InstallToContext(["create_date_fun", CreateDate]);
})
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()));
}
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()));
}
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()));
}
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()));
}
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()));
}
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()));
}
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()));
}
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()));
}
// 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';
// 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';
return args;
}
-$spreadArguments = SpreadArguments;
-$spreadIterable = SpreadIterable;
+// ----------------------------------------------------------------------------
+// Exports
+
+%InstallToContext([
+ "spread_arguments", SpreadArguments,
+ "spread_iterable", SpreadIterable,
+]);
})
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();
}
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;
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_;
};
internalized.Else();
Add<HPushArguments>(key);
HValue* intern_key = Add<HCallRuntime>(
- isolate()->factory()->empty_string(),
Runtime::FunctionForId(Runtime::kInternalizeString), 1);
Push(intern_key);
// 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),
details_compare.Else();
Add<HPushArguments>(receiver, key);
Push(Add<HCallRuntime>(
- isolate()->factory()->empty_string(),
Runtime::FunctionForId(is_strong(language_mode)
? Runtime::kKeyedGetPropertyStrong
: Runtime::kKeyedGetProperty),
// Cache miss, fallback to runtime.
Add<HPushArguments>(object);
Push(Add<HCallRuntime>(
- isolate()->factory()->empty_string(),
Runtime::FunctionForId(Runtime::kNumberToStringSkipCache),
1));
}
{
// 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();
}
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);
} 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();
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
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);
DCHECK(info->IsLoad());
if (is_strong(function_language_mode())) {
return New<HCallRuntime>(
- isolate()->factory()->empty_string(),
Runtime::FunctionForId(Runtime::kThrowStrongModeImplicitConversion),
0);
} else {
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
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();
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());
}
}
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),
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()) {
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);
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();
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
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);
}
return JSONSerialize(key, holder, UNDEFINED, new InternalArray(), "", "");
}
-utils.ExportToRuntime(function(to) {
- to["json_serialize_adapter"] = JsonSerializeAdapter;
-});
+%InstallToContext(["json_serialize_adapter", JsonSerializeAdapter]);
})
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,
+]);
});
$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,
+]);
})
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());
}
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);
}
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(
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);
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,
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),
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(
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);
}
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(
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 =
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
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;
}
// %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
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);
}
}
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
// 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.
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;
}
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,
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,
void PrettyPrinter::VisitCallRuntime(CallRuntime* node) {
- Print("%%");
- PrintLiteral(node->name(), false);
+ Print("%%%s\n", node->debug_name());
PrintArguments(node->arguments());
}
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());
}
var imports = UNDEFINED;
var imports_from_experimental = UNDEFINED;
-var exports_to_runtime = UNDEFINED;
var exports_container = {};
// Export to other scripts.
}
-// 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
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",
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;
// -----------------------------------------------------------------------
-%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;
"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,
+]);
})
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,
+]);
})
var GlobalRegExp = global.RegExp;
var InternalPackedArray = utils.InternalPackedArray;
+var ToNumber;
utils.Import(function(from) {
ToNumber = from.ToNumber;
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;
} 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)) {
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);
}
}
}
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);
}
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);
}
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));
}
}
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);
}
} else {
y = IS_NUMBER(y)
? %_NumberToString(y)
- : %$toString(%$toPrimitive(y, NO_HINT));
+ : %to_string_fun(%to_primitive(y, NO_HINT));
}
}
return %_StringAdd(this, 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);
// 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);
}
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);
}
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);
}
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);
}
if (IS_NUMBER(this) && IS_NUMBER(y)) {
return %NumberMod(this, y);
}
- throw %MakeTypeError(kStrongImplicitConversion);
+ throw %make_type_error(kStrongImplicitConversion);
}
// 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);
}
if (IS_NUMBER(this) && IS_NUMBER(y)) {
return %NumberOr(this, y);
}
- throw %MakeTypeError(kStrongImplicitConversion);
+ throw %make_type_error(kStrongImplicitConversion);
}
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.
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);
}
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);
}
if (IS_NUMBER(this) && IS_NUMBER(y)) {
return %NumberShl(this, y);
}
- throw %MakeTypeError(kStrongImplicitConversion);
+ throw %make_type_error(kStrongImplicitConversion);
}
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.
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);
}
if (IS_NUMBER(this) && IS_NUMBER(y)) {
return %NumberShr(this, y);
}
- throw %MakeTypeError(kStrongImplicitConversion);
+ throw %make_type_error(kStrongImplicitConversion);
}
// 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)) {
}
return %HasElement(x, this);
}
- return %HasProperty(x, %$toName(this));
+ return %HasProperty(x, %to_name(this));
}
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());
}
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());
}
// 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
}
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.
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.
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);
}
// ----------------------------------------------------------------------------
// Exports
-$concatIterableToArray = ConcatIterableToArray;
$defaultNumber = DefaultNumber;
$defaultString = DefaultString;
$NaN = %GetRootNaN();
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;
-})
+});
})
}
-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();
}
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();
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.
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.
}
// 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)) {
#include "src/runtime/runtime.h"
+#include "src/contexts.h"
#include "src/handles-inl.h"
#include "src/heap/heap.h"
#include "src/isolate.h"
} \
,
-
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
#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) \
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 };
// 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;
// Called from a desugaring in the parser.
-var $getTemplateCallSite;
-
(function(global, utils) {
"use strict";
}
-$getTemplateCallSite = function(siteObj, rawStrings, hash) {
+function GetTemplateCallSite(siteObj, rawStrings, hash) {
var cached = GetCachedCallSite(rawStrings, hash);
if (!IS_UNDEFINED(cached)) return cached;
return SetCachedCallSite(%ObjectFreeze(siteObj), hash);
}
+// ----------------------------------------------------------------------------
+// Exports
+
+%InstallToContext(["get_template_call_site", GetTemplateCallSite]);
+
})
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,
+]);
})
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());
}
-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] = {
{"", ""},
// Test call of JS runtime functions.
-var a = %MakeError(0, "error");
-assertInstanceof(a, Error);
+assertEquals("1", %to_string_fun(1));