From a210c3757eed746beba7743385a990bf804bd6e9 Mon Sep 17 00:00:00 2001 From: bmeurer Date: Thu, 5 Nov 2015 03:48:07 -0800 Subject: [PATCH] [runtime] Remove the very dangerous %_CallFunction intrinsic. The %_CallFunction doesn't implement the call sequence properly, it doesn't do the receiver wrapping, nor does it check for classConstructor. Also the eager deoptimization for %_CallFunction was seriously b0rked (we must have been lucky with TurboFan so far). R=yangguo@chromium.org BUG=v8:4413 LOG=n Review URL: https://codereview.chromium.org/1419813010 Cr-Commit-Position: refs/heads/master@{#31821} --- src/compiler/js-intrinsic-lowering.cc | 17 +-- src/compiler/js-intrinsic-lowering.h | 2 +- src/compiler/linkage.cc | 1 - src/crankshaft/hydrogen.cc | 46 -------- src/crankshaft/hydrogen.h | 1 - src/debug/debug.js | 2 +- src/debug/mirrors.js | 60 +++++----- src/full-codegen/arm/full-codegen-arm.cc | 33 ------ src/full-codegen/arm64/full-codegen-arm64.cc | 35 +----- src/full-codegen/full-codegen.h | 1 - src/full-codegen/ia32/full-codegen-ia32.cc | 33 ------ src/full-codegen/mips/full-codegen-mips.cc | 33 ------ .../mips64/full-codegen-mips64.cc | 33 ------ src/full-codegen/ppc/full-codegen-ppc.cc | 33 ------ src/full-codegen/x64/full-codegen-x64.cc | 33 ------ src/full-codegen/x87/full-codegen-x87.cc | 33 ------ src/js/array.js | 2 +- src/js/code-stubs.js | 2 +- src/js/date.js | 6 +- src/js/generator.js | 2 +- src/js/i18n.js | 105 +++++++++--------- src/js/macros.py | 2 +- src/js/messages.js | 60 +++++----- src/js/promise.js | 18 +-- src/js/proxy.js | 6 +- src/js/string.js | 7 +- src/js/templates.js | 6 +- src/js/v8natives.js | 16 +-- src/runtime/runtime-function.cc | 33 ------ src/runtime/runtime.h | 1 - test/cctest/compiler/test-run-intrinsics.cc | 5 +- test/mjsunit/call-runtime-tail.js | 10 +- test/mjsunit/compiler/regress-lazy-deopt.js | 4 +- test/mjsunit/harmony/proxies-function.js | 24 ++-- .../call-function-in-effect-context-deopt.js | 2 +- test/mjsunit/regress/regress-2285.js | 31 ------ test/mjsunit/regress/regress-3183.js | 2 +- test/mjsunit/regress/regress-crbug-405922.js | 2 +- test/mjsunit/strong/function-arity.js | 5 +- 39 files changed, 176 insertions(+), 571 deletions(-) delete mode 100644 test/mjsunit/regress/regress-2285.js diff --git a/src/compiler/js-intrinsic-lowering.cc b/src/compiler/js-intrinsic-lowering.cc index ab169c296c..f11e627e72 100644 --- a/src/compiler/js-intrinsic-lowering.cc +++ b/src/compiler/js-intrinsic-lowering.cc @@ -113,8 +113,8 @@ Reduction JSIntrinsicLowering::Reduce(Node* node) { return ReduceToString(node); case Runtime::kInlineThrowNotDateError: return ReduceThrowNotDateError(node); - case Runtime::kInlineCallFunction: - return ReduceCallFunction(node); + case Runtime::kInlineCall: + return ReduceCall(node); default: break; } @@ -630,17 +630,10 @@ Reduction JSIntrinsicLowering::ReduceToString(Node* node) { } -Reduction JSIntrinsicLowering::ReduceCallFunction(Node* node) { - CallRuntimeParameters params = CallRuntimeParametersOf(node->op()); - size_t arity = params.arity(); - Node* function = node->InputAt(static_cast(arity - 1)); - while (--arity != 0) { - node->ReplaceInput(static_cast(arity), - node->InputAt(static_cast(arity - 1))); - } - node->ReplaceInput(0, function); +Reduction JSIntrinsicLowering::ReduceCall(Node* node) { + size_t const arity = CallRuntimeParametersOf(node->op()).arity(); NodeProperties::ChangeOp( - node, javascript()->CallFunction(params.arity(), STRICT, VectorSlotPair(), + node, javascript()->CallFunction(arity, STRICT, VectorSlotPair(), ConvertReceiverMode::kAny, TailCallMode::kAllow)); return Changed(node); diff --git a/src/compiler/js-intrinsic-lowering.h b/src/compiler/js-intrinsic-lowering.h index 0e0e6118b1..0e029202be 100644 --- a/src/compiler/js-intrinsic-lowering.h +++ b/src/compiler/js-intrinsic-lowering.h @@ -69,7 +69,7 @@ class JSIntrinsicLowering final : public AdvancedReducer { Reduction ReduceToObject(Node* node); Reduction ReduceToPrimitive(Node* node); Reduction ReduceToString(Node* node); - Reduction ReduceCallFunction(Node* node); + Reduction ReduceCall(Node* node); Reduction Change(Node* node, const Operator* op); Reduction Change(Node* node, const Operator* op, Node* a, Node* b); diff --git a/src/compiler/linkage.cc b/src/compiler/linkage.cc index 8878fc8be9..c3f6074fa6 100644 --- a/src/compiler/linkage.cc +++ b/src/compiler/linkage.cc @@ -257,7 +257,6 @@ int Linkage::FrameStateInputCount(Runtime::FunctionId function) { case Runtime::kInlineToString: return 1; case Runtime::kInlineCall: - case Runtime::kInlineCallFunction: case Runtime::kInlineDeoptimizeNow: case Runtime::kInlineThrowNotDateError: return 2; diff --git a/src/crankshaft/hydrogen.cc b/src/crankshaft/hydrogen.cc index 239cd60a72..f238b5b4c8 100644 --- a/src/crankshaft/hydrogen.cc +++ b/src/crankshaft/hydrogen.cc @@ -12714,52 +12714,6 @@ void HOptimizedGraphBuilder::GenerateCall(CallRuntime* call) { } -// Fast call for custom callbacks. -void HOptimizedGraphBuilder::GenerateCallFunction(CallRuntime* call) { - // 1 ~ The function to call is not itself an argument to the call. - int arg_count = call->arguments()->length() - 1; - DCHECK(arg_count >= 1); // There's always at least a receiver. - - CHECK_ALIVE(VisitExpressions(call->arguments())); - // The function is the last argument - HValue* function = Pop(); - // Push the arguments to the stack - PushArgumentsFromEnvironment(arg_count); - - IfBuilder if_is_jsfunction(this); - if_is_jsfunction.If(function, JS_FUNCTION_TYPE); - - if_is_jsfunction.Then(); - { - HInstruction* invoke_result = - Add(function, arg_count); - if (!ast_context()->IsEffect()) { - Push(invoke_result); - } - Add(call->id(), FIXED_SIMULATE); - } - - if_is_jsfunction.Else(); - { - HInstruction* call_result = - Add(function, arg_count); - if (!ast_context()->IsEffect()) { - Push(call_result); - } - Add(call->id(), FIXED_SIMULATE); - } - if_is_jsfunction.End(); - - if (ast_context()->IsEffect()) { - // EffectContext::ReturnValue ignores the value, so we can just pass - // 'undefined' (as we do not have the call result anymore). - return ast_context()->ReturnValue(graph()->GetConstantUndefined()); - } else { - return ast_context()->ReturnValue(Pop()); - } -} - - // Fast call to math functions. void HOptimizedGraphBuilder::GenerateMathPow(CallRuntime* call) { DCHECK_EQ(2, call->arguments()->length()); diff --git a/src/crankshaft/hydrogen.h b/src/crankshaft/hydrogen.h index b141c99fc0..858993981a 100644 --- a/src/crankshaft/hydrogen.h +++ b/src/crankshaft/hydrogen.h @@ -2204,7 +2204,6 @@ class HOptimizedGraphBuilder : public HGraphBuilder, public AstVisitor { F(IsJSProxy) \ F(IsConstructCall) \ F(Call) \ - F(CallFunction) \ F(ArgumentsLength) \ F(Arguments) \ F(ValueOf) \ diff --git a/src/debug/debug.js b/src/debug/debug.js index 933172c08f..50bd0a9c06 100644 --- a/src/debug/debug.js +++ b/src/debug/debug.js @@ -1419,7 +1419,7 @@ DebugCommandProcessor.prototype.processDebugJSONRequest = function( var key = request.command.toLowerCase(); var handler = DebugCommandProcessor.prototype.dispatch_[key]; if (IS_FUNCTION(handler)) { - %_CallFunction(this, request, response, handler); + %_Call(handler, this, request, response); } else { throw MakeError(kDebugger, 'Unknown command "' + request.command + '" in request'); diff --git a/src/debug/mirrors.js b/src/debug/mirrors.js index 9725aa0eb5..5ff3e34955 100644 --- a/src/debug/mirrors.js +++ b/src/debug/mirrors.js @@ -544,7 +544,7 @@ Mirror.prototype.toText = function() { * @extends Mirror */ function ValueMirror(type, value, transient) { - %_CallFunction(this, type, Mirror); + %_Call(Mirror, this, type); this.value_ = value; if (!transient) { this.allocateHandle_(); @@ -590,7 +590,7 @@ ValueMirror.prototype.value = function() { * @extends ValueMirror */ function UndefinedMirror() { - %_CallFunction(this, MirrorType.UNDEFINED_TYPE, UNDEFINED, ValueMirror); + %_Call(ValueMirror, this, MirrorType.UNDEFINED_TYPE, UNDEFINED); } inherits(UndefinedMirror, ValueMirror); @@ -606,7 +606,7 @@ UndefinedMirror.prototype.toText = function() { * @extends ValueMirror */ function NullMirror() { - %_CallFunction(this, MirrorType.NULL_TYPE, null, ValueMirror); + %_Call(ValueMirror, this, MirrorType.NULL_TYPE, null); } inherits(NullMirror, ValueMirror); @@ -623,7 +623,7 @@ NullMirror.prototype.toText = function() { * @extends ValueMirror */ function BooleanMirror(value) { - %_CallFunction(this, MirrorType.BOOLEAN_TYPE, value, ValueMirror); + %_Call(ValueMirror, this, MirrorType.BOOLEAN_TYPE, value); } inherits(BooleanMirror, ValueMirror); @@ -640,7 +640,7 @@ BooleanMirror.prototype.toText = function() { * @extends ValueMirror */ function NumberMirror(value) { - %_CallFunction(this, MirrorType.NUMBER_TYPE, value, ValueMirror); + %_Call(ValueMirror, this, MirrorType.NUMBER_TYPE, value); } inherits(NumberMirror, ValueMirror); @@ -657,7 +657,7 @@ NumberMirror.prototype.toText = function() { * @extends ValueMirror */ function StringMirror(value) { - %_CallFunction(this, MirrorType.STRING_TYPE, value, ValueMirror); + %_Call(ValueMirror, this, MirrorType.STRING_TYPE, value); } inherits(StringMirror, ValueMirror); @@ -686,7 +686,7 @@ StringMirror.prototype.toText = function() { * @extends Mirror */ function SymbolMirror(value) { - %_CallFunction(this, MirrorType.SYMBOL_TYPE, value, ValueMirror); + %_Call(ValueMirror, this, MirrorType.SYMBOL_TYPE, value); } inherits(SymbolMirror, ValueMirror); @@ -697,7 +697,7 @@ SymbolMirror.prototype.description = function() { SymbolMirror.prototype.toText = function() { - return %_CallFunction(this.value_, SymbolToString); + return %_Call(SymbolToString, this.value_); } @@ -711,7 +711,7 @@ SymbolMirror.prototype.toText = function() { */ function ObjectMirror(value, type, transient) { type = type || MirrorType.OBJECT_TYPE; - %_CallFunction(this, type, value, transient, ValueMirror); + %_Call(ValueMirror, this, type, value, transient); } inherits(ObjectMirror, ValueMirror); @@ -961,7 +961,7 @@ ObjectMirror.GetInternalProperties = function(value) { * @extends ObjectMirror */ function FunctionMirror(value) { - %_CallFunction(this, value, MirrorType.FUNCTION_TYPE, ObjectMirror); + %_Call(ObjectMirror, this, value, MirrorType.FUNCTION_TYPE); this.resolved_ = true; } inherits(FunctionMirror, ObjectMirror); @@ -1115,7 +1115,7 @@ FunctionMirror.prototype.toText = function() { function UnresolvedFunctionMirror(value) { // Construct this using the ValueMirror as an unresolved function is not a // real object but just a string. - %_CallFunction(this, MirrorType.FUNCTION_TYPE, value, ValueMirror); + %_Call(ValueMirror, this, MirrorType.FUNCTION_TYPE, value); this.propertyCount_ = 0; this.elementCount_ = 0; this.resolved_ = false; @@ -1165,7 +1165,7 @@ UnresolvedFunctionMirror.prototype.propertyNames = function(kind, limit) { * @extends ObjectMirror */ function ArrayMirror(value) { - %_CallFunction(this, value, ObjectMirror); + %_Call(ObjectMirror, this, value); } inherits(ArrayMirror, ObjectMirror); @@ -1202,7 +1202,7 @@ ArrayMirror.prototype.indexedPropertiesFromRange = function(opt_from_index, * @extends ObjectMirror */ function DateMirror(value) { - %_CallFunction(this, value, ObjectMirror); + %_Call(ObjectMirror, this, value); } inherits(DateMirror, ObjectMirror); @@ -1220,7 +1220,7 @@ DateMirror.prototype.toText = function() { * @extends ObjectMirror */ function RegExpMirror(value) { - %_CallFunction(this, value, MirrorType.REGEXP_TYPE, ObjectMirror); + %_Call(ObjectMirror, this, value, MirrorType.REGEXP_TYPE); } inherits(RegExpMirror, ObjectMirror); @@ -1292,7 +1292,7 @@ RegExpMirror.prototype.toText = function() { * @extends ObjectMirror */ function ErrorMirror(value) { - %_CallFunction(this, value, MirrorType.ERROR_TYPE, ObjectMirror); + %_Call(ObjectMirror, this, value, MirrorType.ERROR_TYPE); } inherits(ErrorMirror, ObjectMirror); @@ -1310,7 +1310,7 @@ ErrorMirror.prototype.toText = function() { // Use the same text representation as in messages.js. var text; try { - text = %_CallFunction(this.value_, ErrorToString); + text = %_Call(ErrorToString, this.value_); } catch (e) { text = '#'; } @@ -1325,7 +1325,7 @@ ErrorMirror.prototype.toText = function() { * @extends ObjectMirror */ function PromiseMirror(value) { - %_CallFunction(this, value, MirrorType.PROMISE_TYPE, ObjectMirror); + %_Call(ObjectMirror, this, value, MirrorType.PROMISE_TYPE); } inherits(PromiseMirror, ObjectMirror); @@ -1354,7 +1354,7 @@ PromiseMirror.prototype.promiseValue = function() { function MapMirror(value) { - %_CallFunction(this, value, MirrorType.MAP_TYPE, ObjectMirror); + %_Call(ObjectMirror, this, value, MirrorType.MAP_TYPE); } inherits(MapMirror, ObjectMirror); @@ -1380,7 +1380,7 @@ MapMirror.prototype.entries = function(opt_limit) { return result; } - var iter = %_CallFunction(this.value_, MapEntries); + var iter = %_Call(MapEntries, this.value_); var next; while ((!opt_limit || result.length < opt_limit) && !(next = iter.next()).done) { @@ -1394,7 +1394,7 @@ MapMirror.prototype.entries = function(opt_limit) { function SetMirror(value) { - %_CallFunction(this, value, MirrorType.SET_TYPE, ObjectMirror); + %_Call(ObjectMirror, this, value, MirrorType.SET_TYPE); } inherits(SetMirror, ObjectMirror); @@ -1403,7 +1403,7 @@ function IteratorGetValues_(iter, next_function, opt_limit) { var result = []; var next; while ((!opt_limit || result.length < opt_limit) && - !(next = %_CallFunction(iter, next_function)).done) { + !(next = %_Call(next_function, iter)).done) { result.push(next.value); } return result; @@ -1422,13 +1422,13 @@ SetMirror.prototype.values = function(opt_limit) { return %GetWeakSetValues(this.value_, opt_limit || 0); } - var iter = %_CallFunction(this.value_, SetValues); + var iter = %_Call(SetValues, this.value_); return IteratorGetValues_(iter, SetIteratorNext, opt_limit); }; function IteratorMirror(value) { - %_CallFunction(this, value, MirrorType.ITERATOR_TYPE, ObjectMirror); + %_Call(ObjectMirror, this, value, MirrorType.ITERATOR_TYPE); } inherits(IteratorMirror, ObjectMirror); @@ -1460,7 +1460,7 @@ IteratorMirror.prototype.preview = function(opt_limit) { * @extends Mirror */ function GeneratorMirror(value) { - %_CallFunction(this, value, MirrorType.GENERATOR_TYPE, ObjectMirror); + %_Call(ObjectMirror, this, value, MirrorType.GENERATOR_TYPE); } inherits(GeneratorMirror, ObjectMirror); @@ -1527,7 +1527,7 @@ GeneratorMirror.prototype.receiver = function() { * @extends Mirror */ function PropertyMirror(mirror, name, details) { - %_CallFunction(this, MirrorType.PROPERTY_TYPE, Mirror); + %_Call(Mirror, this, MirrorType.PROPERTY_TYPE); this.mirror_ = mirror; this.name_ = name; this.value_ = details[0]; @@ -1670,7 +1670,7 @@ PropertyMirror.prototype.isNative = function() { * @extends Mirror */ function InternalPropertyMirror(name, value) { - %_CallFunction(this, MirrorType.INTERNAL_PROPERTY_TYPE, Mirror); + %_Call(Mirror, this, MirrorType.INTERNAL_PROPERTY_TYPE); this.name_ = name; this.value_ = value; } @@ -1883,7 +1883,7 @@ FrameDetails.prototype.stepInPositionsImpl = function() { * @extends Mirror */ function FrameMirror(break_id, index) { - %_CallFunction(this, MirrorType.FRAME_TYPE, Mirror); + %_Call(Mirror, this, MirrorType.FRAME_TYPE); this.break_id_ = break_id; this.index_ = index; this.details_ = new FrameDetails(break_id, index); @@ -2314,7 +2314,7 @@ ScopeDetails.prototype.setVariableValueImpl = function(name, new_value) { * @extends Mirror */ function ScopeMirror(frame, fun, index, opt_details) { - %_CallFunction(this, MirrorType.SCOPE_TYPE, Mirror); + %_Call(Mirror, this, MirrorType.SCOPE_TYPE); if (frame) { this.frame_index_ = frame.index_; } else { @@ -2369,7 +2369,7 @@ ScopeMirror.prototype.setVariableValue = function(name, new_value) { * @extends Mirror */ function ScriptMirror(script) { - %_CallFunction(this, MirrorType.SCRIPT_TYPE, Mirror); + %_Call(Mirror, this, MirrorType.SCRIPT_TYPE); this.script_ = script; this.context_ = new ContextMirror(script.context_data); this.allocateHandle_(); @@ -2490,7 +2490,7 @@ ScriptMirror.prototype.toText = function() { * @extends Mirror */ function ContextMirror(data) { - %_CallFunction(this, MirrorType.CONTEXT_TYPE, Mirror); + %_Call(Mirror, this, MirrorType.CONTEXT_TYPE); this.data_ = data; this.allocateHandle_(); } diff --git a/src/full-codegen/arm/full-codegen-arm.cc b/src/full-codegen/arm/full-codegen-arm.cc index d5758231f1..0e77efe0de 100644 --- a/src/full-codegen/arm/full-codegen-arm.cc +++ b/src/full-codegen/arm/full-codegen-arm.cc @@ -3867,39 +3867,6 @@ void FullCodeGenerator::EmitCall(CallRuntime* expr) { } -void FullCodeGenerator::EmitCallFunction(CallRuntime* expr) { - ZoneList* args = expr->arguments(); - DCHECK(args->length() >= 2); - - int arg_count = args->length() - 2; // 2 ~ receiver and function. - for (int i = 0; i < arg_count + 1; i++) { - VisitForStackValue(args->at(i)); - } - VisitForAccumulatorValue(args->last()); // Function. - - PrepareForBailoutForId(expr->CallId(), NO_REGISTERS); - Label runtime, done; - // Check for non-function argument (including proxy). - __ JumpIfSmi(r0, &runtime); - __ CompareObjectType(r0, r1, r1, JS_FUNCTION_TYPE); - __ b(ne, &runtime); - - // InvokeFunction requires the function in r1. Move it in there. - __ mov(r1, result_register()); - ParameterCount count(arg_count); - __ InvokeFunction(r1, count, CALL_FUNCTION, NullCallWrapper()); - __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); - __ jmp(&done); - - __ bind(&runtime); - __ push(r0); - __ CallRuntime(Runtime::kCallFunction, args->length()); - __ bind(&done); - - context()->Plug(r0); -} - - void FullCodeGenerator::EmitDefaultConstructorCallSuper(CallRuntime* expr) { ZoneList* args = expr->arguments(); DCHECK(args->length() == 2); diff --git a/src/full-codegen/arm64/full-codegen-arm64.cc b/src/full-codegen/arm64/full-codegen-arm64.cc index d7b61f1639..8521a842ac 100644 --- a/src/full-codegen/arm64/full-codegen-arm64.cc +++ b/src/full-codegen/arm64/full-codegen-arm64.cc @@ -3560,7 +3560,7 @@ void FullCodeGenerator::EmitStringAdd(CallRuntime* expr) { void FullCodeGenerator::EmitCall(CallRuntime* expr) { - ASM_LOCATION("FullCodeGenerator::EmitCallFunction"); + ASM_LOCATION("FullCodeGenerator::EmitCall"); ZoneList* args = expr->arguments(); DCHECK_LE(2, args->length()); // Push target, receiver and arguments onto the stack. @@ -3581,39 +3581,6 @@ void FullCodeGenerator::EmitCall(CallRuntime* expr) { } -void FullCodeGenerator::EmitCallFunction(CallRuntime* expr) { - ASM_LOCATION("FullCodeGenerator::EmitCallFunction"); - ZoneList* args = expr->arguments(); - DCHECK(args->length() >= 2); - - int arg_count = args->length() - 2; // 2 ~ receiver and function. - for (int i = 0; i < arg_count + 1; i++) { - VisitForStackValue(args->at(i)); - } - VisitForAccumulatorValue(args->last()); // Function. - - PrepareForBailoutForId(expr->CallId(), NO_REGISTERS); - Label runtime, done; - // Check for non-function argument (including proxy). - __ JumpIfSmi(x0, &runtime); - __ JumpIfNotObjectType(x0, x1, x1, JS_FUNCTION_TYPE, &runtime); - - // InvokeFunction requires the function in x1. Move it in there. - __ Mov(x1, x0); - ParameterCount count(arg_count); - __ InvokeFunction(x1, count, CALL_FUNCTION, NullCallWrapper()); - __ Ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); - __ B(&done); - - __ Bind(&runtime); - __ Push(x0); - __ CallRuntime(Runtime::kCallFunction, args->length()); - __ Bind(&done); - - context()->Plug(x0); -} - - void FullCodeGenerator::EmitDefaultConstructorCallSuper(CallRuntime* expr) { ZoneList* args = expr->arguments(); DCHECK(args->length() == 2); diff --git a/src/full-codegen/full-codegen.h b/src/full-codegen/full-codegen.h index 3aad2e01be..dea4818f0c 100644 --- a/src/full-codegen/full-codegen.h +++ b/src/full-codegen/full-codegen.h @@ -479,7 +479,6 @@ class FullCodeGenerator: public AstVisitor { F(IsJSProxy) \ F(IsConstructCall) \ F(Call) \ - F(CallFunction) \ F(DefaultConstructorCallSuper) \ F(ArgumentsLength) \ F(Arguments) \ diff --git a/src/full-codegen/ia32/full-codegen-ia32.cc b/src/full-codegen/ia32/full-codegen-ia32.cc index bcc0253c30..3c751793d4 100644 --- a/src/full-codegen/ia32/full-codegen-ia32.cc +++ b/src/full-codegen/ia32/full-codegen-ia32.cc @@ -3767,39 +3767,6 @@ void FullCodeGenerator::EmitCall(CallRuntime* expr) { } -void FullCodeGenerator::EmitCallFunction(CallRuntime* expr) { - ZoneList* args = expr->arguments(); - DCHECK(args->length() >= 2); - - int arg_count = args->length() - 2; // 2 ~ receiver and function. - for (int i = 0; i < arg_count + 1; ++i) { - VisitForStackValue(args->at(i)); - } - VisitForAccumulatorValue(args->last()); // Function. - - PrepareForBailoutForId(expr->CallId(), NO_REGISTERS); - Label runtime, done; - // Check for non-function argument (including proxy). - __ JumpIfSmi(eax, &runtime); - __ CmpObjectType(eax, JS_FUNCTION_TYPE, ebx); - __ j(not_equal, &runtime); - - // InvokeFunction requires the function in edi. Move it in there. - __ mov(edi, result_register()); - ParameterCount count(arg_count); - __ InvokeFunction(edi, count, CALL_FUNCTION, NullCallWrapper()); - __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); - __ jmp(&done); - - __ bind(&runtime); - __ push(eax); - __ CallRuntime(Runtime::kCallFunction, args->length()); - __ bind(&done); - - context()->Plug(eax); -} - - void FullCodeGenerator::EmitDefaultConstructorCallSuper(CallRuntime* expr) { ZoneList* args = expr->arguments(); DCHECK(args->length() == 2); diff --git a/src/full-codegen/mips/full-codegen-mips.cc b/src/full-codegen/mips/full-codegen-mips.cc index b3c23563ea..c90731de15 100644 --- a/src/full-codegen/mips/full-codegen-mips.cc +++ b/src/full-codegen/mips/full-codegen-mips.cc @@ -3883,39 +3883,6 @@ void FullCodeGenerator::EmitCall(CallRuntime* expr) { } -void FullCodeGenerator::EmitCallFunction(CallRuntime* expr) { - ZoneList* args = expr->arguments(); - DCHECK(args->length() >= 2); - - int arg_count = args->length() - 2; // 2 ~ receiver and function. - for (int i = 0; i < arg_count + 1; i++) { - VisitForStackValue(args->at(i)); - } - VisitForAccumulatorValue(args->last()); // Function. - - PrepareForBailoutForId(expr->CallId(), NO_REGISTERS); - Label runtime, done; - // Check for non-function argument (including proxy). - __ JumpIfSmi(v0, &runtime); - __ GetObjectType(v0, a1, a1); - __ Branch(&runtime, ne, a1, Operand(JS_FUNCTION_TYPE)); - - // InvokeFunction requires the function in a1. Move it in there. - __ mov(a1, result_register()); - ParameterCount count(arg_count); - __ InvokeFunction(a1, count, CALL_FUNCTION, NullCallWrapper()); - __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); - __ jmp(&done); - - __ bind(&runtime); - __ push(v0); - __ CallRuntime(Runtime::kCallFunction, args->length()); - __ bind(&done); - - context()->Plug(v0); -} - - void FullCodeGenerator::EmitDefaultConstructorCallSuper(CallRuntime* expr) { ZoneList* args = expr->arguments(); DCHECK(args->length() == 2); diff --git a/src/full-codegen/mips64/full-codegen-mips64.cc b/src/full-codegen/mips64/full-codegen-mips64.cc index f38479e099..14c3cf70c1 100644 --- a/src/full-codegen/mips64/full-codegen-mips64.cc +++ b/src/full-codegen/mips64/full-codegen-mips64.cc @@ -3886,39 +3886,6 @@ void FullCodeGenerator::EmitCall(CallRuntime* expr) { } -void FullCodeGenerator::EmitCallFunction(CallRuntime* expr) { - ZoneList* args = expr->arguments(); - DCHECK(args->length() >= 2); - - int arg_count = args->length() - 2; // 2 ~ receiver and function. - for (int i = 0; i < arg_count + 1; i++) { - VisitForStackValue(args->at(i)); - } - VisitForAccumulatorValue(args->last()); // Function. - - PrepareForBailoutForId(expr->CallId(), NO_REGISTERS); - Label runtime, done; - // Check for non-function argument (including proxy). - __ JumpIfSmi(v0, &runtime); - __ GetObjectType(v0, a1, a1); - __ Branch(&runtime, ne, a1, Operand(JS_FUNCTION_TYPE)); - - // InvokeFunction requires the function in a1. Move it in there. - __ mov(a1, result_register()); - ParameterCount count(arg_count); - __ InvokeFunction(a1, count, CALL_FUNCTION, NullCallWrapper()); - __ ld(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); - __ jmp(&done); - - __ bind(&runtime); - __ push(v0); - __ CallRuntime(Runtime::kCallFunction, args->length()); - __ bind(&done); - - context()->Plug(v0); -} - - void FullCodeGenerator::EmitDefaultConstructorCallSuper(CallRuntime* expr) { ZoneList* args = expr->arguments(); DCHECK(args->length() == 2); diff --git a/src/full-codegen/ppc/full-codegen-ppc.cc b/src/full-codegen/ppc/full-codegen-ppc.cc index e0171b7b6c..3f7e23edfa 100644 --- a/src/full-codegen/ppc/full-codegen-ppc.cc +++ b/src/full-codegen/ppc/full-codegen-ppc.cc @@ -3868,39 +3868,6 @@ void FullCodeGenerator::EmitCall(CallRuntime* expr) { } -void FullCodeGenerator::EmitCallFunction(CallRuntime* expr) { - ZoneList* args = expr->arguments(); - DCHECK(args->length() >= 2); - - int arg_count = args->length() - 2; // 2 ~ receiver and function. - for (int i = 0; i < arg_count + 1; i++) { - VisitForStackValue(args->at(i)); - } - VisitForAccumulatorValue(args->last()); // Function. - - PrepareForBailoutForId(expr->CallId(), NO_REGISTERS); - Label runtime, done; - // Check for non-function argument (including proxy). - __ JumpIfSmi(r3, &runtime); - __ CompareObjectType(r3, r4, r4, JS_FUNCTION_TYPE); - __ bne(&runtime); - - // InvokeFunction requires the function in r4. Move it in there. - __ mr(r4, result_register()); - ParameterCount count(arg_count); - __ InvokeFunction(r4, count, CALL_FUNCTION, NullCallWrapper()); - __ LoadP(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); - __ b(&done); - - __ bind(&runtime); - __ push(r3); - __ CallRuntime(Runtime::kCallFunction, args->length()); - __ bind(&done); - - context()->Plug(r3); -} - - void FullCodeGenerator::EmitDefaultConstructorCallSuper(CallRuntime* expr) { ZoneList* args = expr->arguments(); DCHECK(args->length() == 2); diff --git a/src/full-codegen/x64/full-codegen-x64.cc b/src/full-codegen/x64/full-codegen-x64.cc index 8014a72c9c..9420127a48 100644 --- a/src/full-codegen/x64/full-codegen-x64.cc +++ b/src/full-codegen/x64/full-codegen-x64.cc @@ -3763,39 +3763,6 @@ void FullCodeGenerator::EmitCall(CallRuntime* expr) { } -void FullCodeGenerator::EmitCallFunction(CallRuntime* expr) { - ZoneList* args = expr->arguments(); - DCHECK(args->length() >= 2); - - int arg_count = args->length() - 2; // 2 ~ receiver and function. - for (int i = 0; i < arg_count + 1; i++) { - VisitForStackValue(args->at(i)); - } - VisitForAccumulatorValue(args->last()); // Function. - - PrepareForBailoutForId(expr->CallId(), TOS_REG); - Label runtime, done; - // Check for non-function argument (including proxy). - __ JumpIfSmi(rax, &runtime); - __ CmpObjectType(rax, JS_FUNCTION_TYPE, rbx); - __ j(not_equal, &runtime); - - // InvokeFunction requires the function in rdi. Move it in there. - __ movp(rdi, result_register()); - ParameterCount count(arg_count); - __ InvokeFunction(rdi, count, CALL_FUNCTION, NullCallWrapper()); - __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); - __ jmp(&done); - - __ bind(&runtime); - __ Push(rax); - __ CallRuntime(Runtime::kCallFunction, args->length()); - __ bind(&done); - - context()->Plug(rax); -} - - void FullCodeGenerator::EmitDefaultConstructorCallSuper(CallRuntime* expr) { ZoneList* args = expr->arguments(); DCHECK(args->length() == 2); diff --git a/src/full-codegen/x87/full-codegen-x87.cc b/src/full-codegen/x87/full-codegen-x87.cc index b7c87f0e26..b3557d4e7d 100644 --- a/src/full-codegen/x87/full-codegen-x87.cc +++ b/src/full-codegen/x87/full-codegen-x87.cc @@ -3760,39 +3760,6 @@ void FullCodeGenerator::EmitCall(CallRuntime* expr) { } -void FullCodeGenerator::EmitCallFunction(CallRuntime* expr) { - ZoneList* args = expr->arguments(); - DCHECK(args->length() >= 2); - - int arg_count = args->length() - 2; // 2 ~ receiver and function. - for (int i = 0; i < arg_count + 1; ++i) { - VisitForStackValue(args->at(i)); - } - VisitForAccumulatorValue(args->last()); // Function. - - PrepareForBailoutForId(expr->CallId(), NO_REGISTERS); - Label runtime, done; - // Check for non-function argument (including proxy). - __ JumpIfSmi(eax, &runtime); - __ CmpObjectType(eax, JS_FUNCTION_TYPE, ebx); - __ j(not_equal, &runtime); - - // InvokeFunction requires the function in edi. Move it in there. - __ mov(edi, result_register()); - ParameterCount count(arg_count); - __ InvokeFunction(edi, count, CALL_FUNCTION, NullCallWrapper()); - __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); - __ jmp(&done); - - __ bind(&runtime); - __ push(eax); - __ CallRuntime(Runtime::kCallFunction, args->length()); - __ bind(&done); - - context()->Plug(eax); -} - - void FullCodeGenerator::EmitDefaultConstructorCallSuper(CallRuntime* expr) { ZoneList* args = expr->arguments(); DCHECK(args->length() == 2); diff --git a/src/js/array.js b/src/js/array.js index b9a49284e7..294e474be6 100644 --- a/src/js/array.js +++ b/src/js/array.js @@ -405,7 +405,7 @@ function ArrayToString() { func = array.join; } if (!IS_CALLABLE(func)) { - return %_CallFunction(array, ObjectToString); + return %_Call(ObjectToString, array); } return %_Call(func, array); } diff --git a/src/js/code-stubs.js b/src/js/code-stubs.js index ab06f6c63b..7cb10d726a 100644 --- a/src/js/code-stubs.js +++ b/src/js/code-stubs.js @@ -35,7 +35,7 @@ code_stubs.MathFloorStub = function MathFloorStub(call_conv, minor_key) { // |tv| is the calling function's type vector // |v| is the value to floor if (f !== %_FixedArrayGet(tv, i|0)) { - return %_CallFunction(receiver, v, f); + return %_Call(f, receiver, v); } var r = %_MathFloor(+v); if (%_IsMinusZero(r)) { diff --git a/src/js/date.js b/src/js/date.js index 1e8ef16679..a99d8e4d51 100644 --- a/src/js/date.js +++ b/src/js/date.js @@ -134,7 +134,7 @@ var Date_cache = { function DateConstructor(year, month, date, hours, minutes, seconds, ms) { if (!%_IsConstructCall()) { // ECMA 262 - 15.9.2 - return %_CallFunction(new GlobalDate(), DateToString); + return %_Call(DateToString, new GlobalDate()); } // ECMA 262 - 15.9.3 @@ -337,7 +337,7 @@ function DateToTimeString() { // ECMA 262 - 15.9.5.5 function DateToLocaleString() { CHECK_DATE(this); - return %_CallFunction(this, DateToString); + return %_Call(DateToString, this); } @@ -735,7 +735,7 @@ function DateSetYear(year) { // do that either. Instead, we create a new function whose name // property will return toGMTString. function DateToGMTString() { - return %_CallFunction(this, DateToUTCString); + return %_Call(DateToUTCString, this); } diff --git a/src/js/generator.js b/src/js/generator.js index 4d3f319125..2f61b3f22c 100644 --- a/src/js/generator.js +++ b/src/js/generator.js @@ -84,7 +84,7 @@ function GeneratorFunctionConstructor(arg1) { // length == 1 var global_proxy = %GlobalProxy(GeneratorFunctionConstructor); // Compile the string in the constructor and not a helper so that errors // appear to come from here. - var func = %_CallFunction(global_proxy, %CompileString(source, true)); + var func = %_Call(%CompileString(source, true), global_proxy); // Set name-should-print-as-anonymous flag on the ShareFunctionInfo and // ensure that |func| uses correct initial map from |new.target| if // it's available. diff --git a/src/js/i18n.js b/src/js/i18n.js index 949595abdb..f2b9dd4445 100644 --- a/src/js/i18n.js +++ b/src/js/i18n.js @@ -249,7 +249,7 @@ function addBoundMethod(obj, methodName, implementation, length) { * Parameter locales is treated as a priority list. */ function supportedLocalesOf(service, locales, options) { - if (IS_NULL(%_CallFunction(service, GetServiceRE(), StringMatch))) { + if (IS_NULL(%_Call(StringMatch, service, GetServiceRE()))) { throw MakeError(kWrongServiceType, service); } @@ -297,20 +297,22 @@ function lookupSupportedLocalesOf(requestedLocales, availableLocales) { var matchedLocales = []; for (var i = 0; i < requestedLocales.length; ++i) { // Remove -u- extension. - var locale = %_CallFunction(requestedLocales[i], GetUnicodeExtensionRE(), - '', StringReplace); + var locale = %_Call(StringReplace, + requestedLocales[i], + GetUnicodeExtensionRE(), + ''); do { if (!IS_UNDEFINED(availableLocales[locale])) { // Push requested locale not the resolved one. - %_CallFunction(matchedLocales, requestedLocales[i], ArrayPush); + %_Call(ArrayPush, matchedLocales, requestedLocales[i]); break; } // Truncate locale if possible, if not break. - var pos = %_CallFunction(locale, '-', StringLastIndexOf); + var pos = %_Call(StringLastIndexOf, locale, '-'); if (pos === -1) { break; } - locale = %_CallFunction(locale, 0, pos, StringSubstring); + locale = %_Call(StringSubstring, locale, 0, pos); } while (true); } @@ -355,8 +357,7 @@ function getGetOption(options, caller) { throw MakeError(kWrongValueType); } - if (!IS_UNDEFINED(values) && - %_CallFunction(values, value, ArrayIndexOf) === -1) { + if (!IS_UNDEFINED(values) && %_Call(ArrayIndexOf, values, value) === -1) { throw MakeRangeError(kValueOutOfRange, value, caller, property); } @@ -405,7 +406,7 @@ function resolveLocale(service, requestedLocales, options) { * lookup algorithm. */ function lookupMatcher(service, requestedLocales) { - if (IS_NULL(%_CallFunction(service, GetServiceRE(), StringMatch))) { + if (IS_NULL(%_Call(StringMatch, service, GetServiceRE()))) { throw MakeError(kWrongServiceType, service); } @@ -416,23 +417,22 @@ function lookupMatcher(service, requestedLocales) { for (var i = 0; i < requestedLocales.length; ++i) { // Remove all extensions. - var locale = %_CallFunction(requestedLocales[i], GetAnyExtensionRE(), '', - StringReplace); + var locale = %_Call(StringReplace, requestedLocales[i], + GetAnyExtensionRE(), ''); do { if (!IS_UNDEFINED(AVAILABLE_LOCALES[service][locale])) { // Return the resolved locale and extension. var extensionMatch = - %_CallFunction(requestedLocales[i], GetUnicodeExtensionRE(), - StringMatch); + %_Call(StringMatch, requestedLocales[i], GetUnicodeExtensionRE()); var extension = IS_NULL(extensionMatch) ? '' : extensionMatch[0]; return {'locale': locale, 'extension': extension, 'position': i}; } // Truncate locale if possible. - var pos = %_CallFunction(locale, '-', StringLastIndexOf); + var pos = %_Call(StringLastIndexOf, locale, '-'); if (pos === -1) { break; } - locale = %_CallFunction(locale, 0, pos, StringSubstring); + locale = %_Call(StringSubstring, locale, 0, pos); } while (true); } @@ -461,7 +461,7 @@ function bestFitMatcher(service, requestedLocales) { * We are not concerned with the validity of the values at this point. */ function parseExtension(extension) { - var extensionSplit = %_CallFunction(extension, '-', StringSplit); + var extensionSplit = %_Call(StringSplit, extension, '-'); // Assume ['', 'u', ...] input, but don't throw. if (extensionSplit.length <= 2 || @@ -598,7 +598,7 @@ function getOptimalLanguageTag(original, resolved) { // Preserve extensions of resolved locale, but swap base tags with original. var resolvedBase = new GlobalRegExp('^' + locales[1].base); - return %_CallFunction(resolved, resolvedBase, locales[0].base, StringReplace); + return %_Call(StringReplace, resolved, resolvedBase, locales[0].base); } @@ -613,8 +613,8 @@ function getAvailableLocalesOf(service) { for (var i in available) { if (%HasOwnProperty(available, i)) { - var parts = %_CallFunction(i, /^([a-z]{2,3})-([A-Z][a-z]{3})-([A-Z]{2})$/, - StringMatch); + var parts = + %_Call(StringMatch, i, /^([a-z]{2,3})-([A-Z][a-z]{3})-([A-Z]{2})$/); if (parts !== null) { // Build xx-ZZ. We don't care about the actual value, // as long it's not undefined. @@ -674,8 +674,8 @@ function addWECPropertyIfDefined(object, property, value) { * Returns titlecased word, aMeRricA -> America. */ function toTitleCaseWord(word) { - return %StringToUpperCase(%_CallFunction(word, 0, 1, StringSubstr)) + - %StringToLowerCase(%_CallFunction(word, 1, StringSubstr)); + return %StringToUpperCase(%_Call(StringSubstr, word, 0, 1)) + + %StringToLowerCase(%_Call(StringSubstr, word, 1)); } /** @@ -719,7 +719,7 @@ function initializeLocaleList(locales) { } else { // We allow single string localeID. if (typeof locales === 'string') { - %_CallFunction(seen, canonicalizeLanguageTag(locales), ArrayPush); + %_Call(ArrayPush, seen, canonicalizeLanguageTag(locales)); return freezeArray(seen); } @@ -732,8 +732,8 @@ function initializeLocaleList(locales) { var tag = canonicalizeLanguageTag(value); - if (%_CallFunction(seen, tag, ArrayIndexOf) === -1) { - %_CallFunction(seen, tag, ArrayPush); + if (%_Call(ArrayIndexOf, seen, tag) === -1) { + %_Call(ArrayPush, seen, tag); } } } @@ -754,40 +754,40 @@ function initializeLocaleList(locales) { */ function isValidLanguageTag(locale) { // Check if it's well-formed, including grandfadered tags. - if (!%_CallFunction(GetLanguageTagRE(), locale, RegExpTest)) { + if (!%_Call(RegExpTest, GetLanguageTagRE(), locale)) { return false; } // Just return if it's a x- form. It's all private. - if (%_CallFunction(locale, 'x-', StringIndexOf) === 0) { + if (%_Call(StringIndexOf, locale, 'x-') === 0) { return true; } // Check if there are any duplicate variants or singletons (extensions). // Remove private use section. - locale = %_CallFunction(locale, /-x-/, StringSplit)[0]; + locale = %_Call(StringSplit, locale, /-x-/)[0]; // Skip language since it can match variant regex, so we start from 1. // We are matching i-klingon here, but that's ok, since i-klingon-klingon // is not valid and would fail LANGUAGE_TAG_RE test. var variants = []; var extensions = []; - var parts = %_CallFunction(locale, /-/, StringSplit); + var parts = %_Call(StringSplit, locale, /-/); for (var i = 1; i < parts.length; i++) { var value = parts[i]; - if (%_CallFunction(GetLanguageVariantRE(), value, RegExpTest) && + if (%_Call(RegExpTest, GetLanguageVariantRE(), value) && extensions.length === 0) { - if (%_CallFunction(variants, value, ArrayIndexOf) === -1) { - %_CallFunction(variants, value, ArrayPush); + if (%_Call(ArrayIndexOf, variants, value) === -1) { + %_Call(ArrayPush, variants, value); } else { return false; } } - if (%_CallFunction(GetLanguageSingletonRE(), value, RegExpTest)) { - if (%_CallFunction(extensions, value, ArrayIndexOf) === -1) { - %_CallFunction(extensions, value, ArrayPush); + if (%_Call(RegExpTest, GetLanguageSingletonRE(), value)) { + if (%_Call(ArrayIndexOf, extensions, value) === -1) { + %_Call(ArrayPush, extensions, value); } else { return false; } @@ -901,8 +901,7 @@ function initializeCollator(collator, locales, options) { 'pinyin', 'reformed', 'searchjl', 'stroke', 'trad', 'unihan', 'zhuyin' ]; - if (%_CallFunction(ALLOWED_CO_VALUES, extensionMap.co, ArrayIndexOf) !== - -1) { + if (%_Call(ArrayIndexOf, ALLOWED_CO_VALUES, extensionMap.co) !== -1) { extension = '-u-co-' + extensionMap.co; // ICU can't tell us what the collation is, so save user's input. collation = extensionMap.co; @@ -1042,7 +1041,7 @@ addBoundMethod(Intl.Collator, 'compare', compare, 2); function isWellFormedCurrencyCode(currency) { return typeof currency == "string" && currency.length == 3 && - %_CallFunction(currency, /[^A-Za-z]/, StringMatch) == null; + %_Call(StringMatch, currency, /[^A-Za-z]/) == null; } @@ -1371,58 +1370,57 @@ function appendToLDMLString(option, pairs) { */ function fromLDMLString(ldmlString) { // First remove '' quoted text, so we lose 'Uhr' strings. - ldmlString = %_CallFunction(ldmlString, GetQuotedStringRE(), '', - StringReplace); + ldmlString = %_Call(StringReplace, ldmlString, GetQuotedStringRE(), ''); var options = {}; - var match = %_CallFunction(ldmlString, /E{3,5}/g, StringMatch); + var match = %_Call(StringMatch, ldmlString, /E{3,5}/g); options = appendToDateTimeObject( options, 'weekday', match, {EEEEE: 'narrow', EEE: 'short', EEEE: 'long'}); - match = %_CallFunction(ldmlString, /G{3,5}/g, StringMatch); + match = %_Call(StringMatch, ldmlString, /G{3,5}/g); options = appendToDateTimeObject( options, 'era', match, {GGGGG: 'narrow', GGG: 'short', GGGG: 'long'}); - match = %_CallFunction(ldmlString, /y{1,2}/g, StringMatch); + match = %_Call(StringMatch, ldmlString, /y{1,2}/g); options = appendToDateTimeObject( options, 'year', match, {y: 'numeric', yy: '2-digit'}); - match = %_CallFunction(ldmlString, /M{1,5}/g, StringMatch); + match = %_Call(StringMatch, ldmlString, /M{1,5}/g); options = appendToDateTimeObject(options, 'month', match, {MM: '2-digit', M: 'numeric', MMMMM: 'narrow', MMM: 'short', MMMM: 'long'}); // Sometimes we get L instead of M for month - standalone name. - match = %_CallFunction(ldmlString, /L{1,5}/g, StringMatch); + match = %_Call(StringMatch, ldmlString, /L{1,5}/g); options = appendToDateTimeObject(options, 'month', match, {LL: '2-digit', L: 'numeric', LLLLL: 'narrow', LLL: 'short', LLLL: 'long'}); - match = %_CallFunction(ldmlString, /d{1,2}/g, StringMatch); + match = %_Call(StringMatch, ldmlString, /d{1,2}/g); options = appendToDateTimeObject( options, 'day', match, {d: 'numeric', dd: '2-digit'}); - match = %_CallFunction(ldmlString, /h{1,2}/g, StringMatch); + match = %_Call(StringMatch, ldmlString, /h{1,2}/g); if (match !== null) { options['hour12'] = true; } options = appendToDateTimeObject( options, 'hour', match, {h: 'numeric', hh: '2-digit'}); - match = %_CallFunction(ldmlString, /H{1,2}/g, StringMatch); + match = %_Call(StringMatch, ldmlString, /H{1,2}/g); if (match !== null) { options['hour12'] = false; } options = appendToDateTimeObject( options, 'hour', match, {H: 'numeric', HH: '2-digit'}); - match = %_CallFunction(ldmlString, /m{1,2}/g, StringMatch); + match = %_Call(StringMatch, ldmlString, /m{1,2}/g); options = appendToDateTimeObject( options, 'minute', match, {m: 'numeric', mm: '2-digit'}); - match = %_CallFunction(ldmlString, /s{1,2}/g, StringMatch); + match = %_Call(StringMatch, ldmlString, /s{1,2}/g); options = appendToDateTimeObject( options, 'second', match, {s: 'numeric', ss: '2-digit'}); - match = %_CallFunction(ldmlString, /z|zzzz/g, StringMatch); + match = %_Call(StringMatch, ldmlString, /z|zzzz/g); options = appendToDateTimeObject( options, 'timeZoneName', match, {z: 'short', zzzz: 'long'}); @@ -1755,7 +1753,7 @@ function canonicalizeTimeZoneID(tzID) { // We expect only _ and / beside ASCII letters. // All inputs should conform to Area/Location from now on. - var match = %_CallFunction(tzID, GetTimezoneNameCheckRE(), StringMatch); + var match = %_Call(StringMatch, tzID, GetTimezoneNameCheckRE()); if (IS_NULL(match)) throw MakeRangeError(kExpectedLocation, tzID); var result = toTitleCaseWord(match[1]) + '/' + toTitleCaseWord(match[2]); @@ -2017,11 +2015,10 @@ OverrideFunction(GlobalString.prototype, 'normalize', function() { var NORMALIZATION_FORMS = ['NFC', 'NFD', 'NFKC', 'NFKD']; - var normalizationForm = - %_CallFunction(NORMALIZATION_FORMS, form, ArrayIndexOf); + var normalizationForm = %_Call(ArrayIndexOf, NORMALIZATION_FORMS, form); if (normalizationForm === -1) { throw MakeRangeError(kNormalizationForm, - %_CallFunction(NORMALIZATION_FORMS, ', ', ArrayJoin)); + %_Call(ArrayJoin, NORMALIZATION_FORMS, ', ')); } return %StringNormalize(s, normalizationForm); diff --git a/src/js/macros.py b/src/js/macros.py index f9bb12b705..a293a1b6c2 100644 --- a/src/js/macros.py +++ b/src/js/macros.py @@ -160,7 +160,7 @@ macro TO_PRIMITIVE_NUMBER(arg) = (%_ToPrimitive_Number(arg)); macro TO_PRIMITIVE_STRING(arg) = (%_ToPrimitive_String(arg)); macro TO_NAME(arg) = (%_ToName(arg)); macro JSON_NUMBER_TO_STRING(arg) = ((%_IsSmi(%IS_VAR(arg)) || arg - arg == 0) ? %_NumberToString(arg) : "null"); -macro HAS_OWN_PROPERTY(arg, index) = (%_CallFunction(arg, index, ObjectHasOwnProperty)); +macro HAS_OWN_PROPERTY(arg, index) = (%_Call(ObjectHasOwnProperty, arg, index)); macro HAS_INDEX(array, index, is_array) = ((is_array && %_HasFastPackedElements(%IS_VAR(array))) ? (index < array.length) : (index in array)); # Private names. diff --git a/src/js/messages.js b/src/js/messages.js index 481d3eb106..6eac9828e6 100644 --- a/src/js/messages.js +++ b/src/js/messages.js @@ -91,26 +91,26 @@ function NoSideEffectToString(obj) { if (IS_UNDEFINED(obj)) return 'undefined'; if (IS_NULL(obj)) return 'null'; if (IS_FUNCTION(obj)) { - var str = %_CallFunction(obj, obj, FunctionSourceString); + var str = %_Call(FunctionSourceString, obj, obj); if (str.length > 128) { str = %_SubString(str, 0, 111) + "......" + %_SubString(str, str.length - 2, str.length); } return str; } - if (IS_SYMBOL(obj)) return %_CallFunction(obj, SymbolToString); + if (IS_SYMBOL(obj)) return %_Call(SymbolToString, obj); if (IS_SIMD_VALUE(obj)) { switch (typeof(obj)) { - case 'float32x4': return %_CallFunction(obj, Float32x4ToString); - case 'int32x4': return %_CallFunction(obj, Int32x4ToString); - case 'int16x8': return %_CallFunction(obj, Int16x8ToString); - case 'int8x16': return %_CallFunction(obj, Int8x16ToString); - case 'uint32x4': return %_CallFunction(obj, Uint32x4ToString); - case 'uint16x8': return %_CallFunction(obj, Uint16x8ToString); - case 'uint8x16': return %_CallFunction(obj, Uint8x16ToString); - case 'bool32x4': return %_CallFunction(obj, Bool32x4ToString); - case 'bool16x8': return %_CallFunction(obj, Bool16x8ToString); - case 'bool8x16': return %_CallFunction(obj, Bool8x16ToString); + case 'float32x4': return %_Call(Float32x4ToString, obj); + case 'int32x4': return %_Call(Int32x4ToString, obj); + case 'int16x8': return %_Call(Int16x8ToString, obj); + case 'int8x16': return %_Call(Int8x16ToString, obj); + case 'uint32x4': return %_Call(Uint32x4ToString, obj); + case 'uint16x8': return %_Call(Uint16x8ToString, obj); + case 'uint8x16': return %_Call(Uint8x16ToString, obj); + case 'bool32x4': return %_Call(Bool32x4ToString, obj); + case 'bool16x8': return %_Call(Bool16x8ToString, obj); + case 'bool8x16': return %_Call(Bool8x16ToString, obj); } } if (IS_OBJECT(obj) @@ -124,10 +124,10 @@ function NoSideEffectToString(obj) { } } if (CanBeSafelyTreatedAsAnErrorObject(obj)) { - return %_CallFunction(obj, ErrorToString); + return %_Call(ErrorToString, obj); } - return %_CallFunction(obj, NoSideEffectsObjectToString); + return %_Call(NoSideEffectsObjectToString, obj); } // To determine whether we can safely stringify an object using ErrorToString @@ -158,7 +158,7 @@ function CanBeSafelyTreatedAsAnErrorObject(obj) { // objects between script tags in a browser setting. function ToStringCheckErrorObject(obj) { if (CanBeSafelyTreatedAsAnErrorObject(obj)) { - return %_CallFunction(obj, ErrorToString); + return %_Call(ErrorToString, obj); } else { return TO_STRING(obj); } @@ -296,7 +296,7 @@ function ScriptLocationFromPosition(position, var line_ends = this.line_ends; var start = line == 0 ? 0 : line_ends[line - 1] + 1; var end = line_ends[line]; - if (end > 0 && %_CallFunction(this.source, end - 1, StringCharAt) == '\r') { + if (end > 0 && %_Call(StringCharAt, this.source, end - 1) == '\r') { end--; } var column = position - start; @@ -419,7 +419,7 @@ function ScriptSourceLine(opt_line) { var line_ends = this.line_ends; var start = line == 0 ? 0 : line_ends[line - 1] + 1; var end = line_ends[line]; - return %_CallFunction(this.source, start, end, StringSubstring); + return %_Call(StringSubstring, this.source, start, end); } @@ -518,10 +518,7 @@ function SourceLocation(script, position, line, column, start, end) { * Source text for this location. */ function SourceLocationSourceText() { - return %_CallFunction(this.script.source, - this.start, - this.end, - StringSubstring); + return %_Call(StringSubstring, this.script.source, this.start, this.end); } @@ -563,10 +560,10 @@ function SourceSlice(script, from_line, to_line, from_position, to_position) { * the line terminating characters (if any) */ function SourceSliceSourceText() { - return %_CallFunction(this.script.source, - this.from_position, - this.to_position, - StringSubstring); + return %_Call(StringSubstring, + this.script.source, + this.from_position, + this.to_position); } utils.SetUpLockedPrototype(SourceSlice, @@ -694,13 +691,12 @@ function CallSiteToString() { var typeName = GetTypeName(GET_PRIVATE(this, callSiteReceiverSymbol), true); var methodName = this.getMethodName(); if (functionName) { - if (typeName && - %_CallFunction(functionName, typeName, StringIndexOf) != 0) { + if (typeName && %_Call(StringIndexOf, functionName, typeName) != 0) { line += typeName + "."; } line += functionName; if (methodName && - (%_CallFunction(functionName, "." + methodName, StringIndexOf) != + (%_Call(StringIndexOf, functionName, "." + methodName) != functionName.length - methodName.length - 1)) { line += " [as " + methodName + "]"; } @@ -782,7 +778,7 @@ function FormatEvalOrigin(script) { function FormatErrorString(error) { try { - return %_CallFunction(error, ErrorToString); + return %_Call(ErrorToString, error); } catch (e) { try { return ""; @@ -848,7 +844,7 @@ function FormatStackTrace(obj, raw_stack) { } lines.push(" at " + line); } - return %_CallFunction(lines, "\n", ArrayJoin); + return %_Call(ArrayJoin, lines, "\n"); } @@ -857,12 +853,12 @@ function GetTypeName(receiver, requireConstructor) { var constructor = receiver.constructor; if (!constructor) { return requireConstructor ? null : - %_CallFunction(receiver, NoSideEffectsObjectToString); + %_Call(NoSideEffectsObjectToString, receiver); } var constructorName = constructor.name; if (!constructorName) { return requireConstructor ? null : - %_CallFunction(receiver, NoSideEffectsObjectToString); + %_Call(NoSideEffectsObjectToString, receiver); } return constructorName; } diff --git a/src/js/promise.js b/src/js/promise.js index ab9ffd8a3a..d7e9a5c67f 100644 --- a/src/js/promise.js +++ b/src/js/promise.js @@ -90,10 +90,10 @@ function PromiseCoerce(constructor, x) { try { then = x.then; } catch(r) { - return %_CallFunction(constructor, r, PromiseRejected); + return %_Call(PromiseRejected, constructor, r); } if (IS_CALLABLE(then)) { - var deferred = %_CallFunction(constructor, PromiseDeferred); + var deferred = %_Call(PromiseDeferred, constructor); try { %_Call(then, x, deferred.resolve, deferred.reject); } catch(r) { @@ -112,7 +112,7 @@ function PromiseHandle(value, handler, deferred) { if (result === deferred.promise) throw MakeTypeError(kPromiseCyclic, result); else if (IsPromise(result)) - %_CallFunction(result, deferred.resolve, deferred.reject, PromiseChain); + %_Call(PromiseChain, result, deferred.resolve, deferred.reject); else deferred.resolve(result); } catch (exception) { @@ -226,7 +226,7 @@ function PromiseRejected(r) { function PromiseChain(onResolve, onReject) { // a.k.a. flatMap onResolve = IS_UNDEFINED(onResolve) ? PromiseIdResolveHandler : onResolve; onReject = IS_UNDEFINED(onReject) ? PromiseIdRejectHandler : onReject; - var deferred = %_CallFunction(this.constructor, PromiseDeferred); + var deferred = %_Call(PromiseDeferred, this.constructor); switch (GET_PRIVATE(this, promiseStatusSymbol)) { case UNDEFINED: throw MakeTypeError(kNotAPromise, this); @@ -269,7 +269,8 @@ function PromiseThen(onResolve, onReject) { onReject = IS_CALLABLE(onReject) ? onReject : PromiseIdRejectHandler; var that = this; var constructor = this.constructor; - return %_CallFunction( + return %_Call( + PromiseChain, this, function(x) { x = PromiseCoerce(constructor, x); @@ -283,8 +284,7 @@ function PromiseThen(onResolve, onReject) { return onResolve(x); } }, - onReject, - PromiseChain + onReject ); } @@ -299,7 +299,7 @@ function PromiseCast(x) { } function PromiseAll(iterable) { - var deferred = %_CallFunction(this, PromiseDeferred); + var deferred = %_Call(PromiseDeferred, this); var resolutions = []; try { var count = 0; @@ -331,7 +331,7 @@ function PromiseAll(iterable) { } function PromiseRace(iterable) { - var deferred = %_CallFunction(this, PromiseDeferred); + var deferred = %_Call(PromiseDeferred, this); try { for (var value of iterable) { var reject = function(r) { deferred.reject(r) }; diff --git a/src/js/proxy.js b/src/js/proxy.js index 56373861ee..fc38680a13 100644 --- a/src/js/proxy.js +++ b/src/js/proxy.js @@ -81,7 +81,7 @@ function DerivedGetTrap(receiver, name) { } else { if (IS_UNDEFINED(desc.get)) { return desc.get } // The proposal says: desc.get.call(receiver) - return %_CallFunction(receiver, desc.get) + return %_Call(desc.get, receiver) } } @@ -99,7 +99,7 @@ function DerivedSetTrap(receiver, name, val) { } else { // accessor if (desc.set) { // The proposal says: desc.set.call(receiver, val) - %_CallFunction(receiver, val, desc.set) + %_Call(desc.set, receiver, val) return true } else { return false @@ -117,7 +117,7 @@ function DerivedSetTrap(receiver, name, val) { } else { // accessor if (desc.set) { // The proposal says: desc.set.call(receiver, val) - %_CallFunction(receiver, val, desc.set) + %_Call(desc.set, receiver, val) return true } else { return false diff --git a/src/js/string.js b/src/js/string.js index 0fdd7ae342..1a31fd1df3 100644 --- a/src/js/string.js +++ b/src/js/string.js @@ -179,11 +179,10 @@ function StringNormalizeJS() { var form = IS_UNDEFINED(formArg) ? 'NFC' : TO_STRING(formArg); var NORMALIZATION_FORMS = ['NFC', 'NFD', 'NFKC', 'NFKD']; - var normalizationForm = - %_CallFunction(NORMALIZATION_FORMS, form, ArrayIndexOf); + var normalizationForm = %_Call(ArrayIndexOf, NORMALIZATION_FORMS, form); if (normalizationForm === -1) { throw MakeRangeError(kNormalizationForm, - %_CallFunction(NORMALIZATION_FORMS, ', ', ArrayJoin)); + %_Call(ArrayJoin, NORMALIZATION_FORMS, ', ')); } return s; @@ -803,7 +802,7 @@ function StringFromCharCode(code) { // ES6 draft, revision 26 (2014-07-18), section B.2.3.2.1 function HtmlEscape(str) { - return %_CallFunction(TO_STRING(str), /"/g, """, StringReplace); + return %_Call(StringReplace, TO_STRING(str), /"/g, """); } diff --git a/src/js/templates.js b/src/js/templates.js index b273bc39e8..eee6b7d7e7 100644 --- a/src/js/templates.js +++ b/src/js/templates.js @@ -38,7 +38,7 @@ function SameCallSiteElements(rawStrings, other) { function GetCachedCallSite(siteObj, hash) { - var obj = %_CallFunction(callSiteCache, hash, mapGetFn); + var obj = %_Call(mapGetFn, callSiteCache, hash); if (IS_UNDEFINED(obj)) return; @@ -50,13 +50,13 @@ function GetCachedCallSite(siteObj, hash) { function SetCachedCallSite(siteObj, hash) { - var obj = %_CallFunction(callSiteCache, hash, mapGetFn); + var obj = %_Call(mapGetFn, callSiteCache, hash); var array; if (IS_UNDEFINED(obj)) { array = new InternalArray(1); array[0] = siteObj; - %_CallFunction(callSiteCache, hash, array, mapSetFn); + %_Call(mapSetFn, callSiteCache, hash, array); } else { obj.push(siteObj); } diff --git a/src/js/v8natives.js b/src/js/v8natives.js index d76b54eaf2..f6b394c2e7 100644 --- a/src/js/v8natives.js +++ b/src/js/v8natives.js @@ -117,7 +117,7 @@ function GlobalEval(x) { var f = %CompileString(x, false); if (!IS_FUNCTION(f)) return f; - return %_CallFunction(global_proxy, f); + return %_Call(f, global_proxy); } @@ -554,17 +554,17 @@ function GetTrap(handler, name, defaultTrap) { function CallTrap0(handler, name, defaultTrap) { - return %_CallFunction(handler, GetTrap(handler, name, defaultTrap)); + return %_Call(GetTrap(handler, name, defaultTrap), handler); } function CallTrap1(handler, name, defaultTrap, x) { - return %_CallFunction(handler, x, GetTrap(handler, name, defaultTrap)); + return %_Call(GetTrap(handler, name, defaultTrap), handler, x); } function CallTrap2(handler, name, defaultTrap, x, y) { - return %_CallFunction(handler, x, y, GetTrap(handler, name, defaultTrap)); + return %_Call(GetTrap(handler, name, defaultTrap), handler, x, y); } @@ -1463,7 +1463,7 @@ function NumberToStringJS(radix) { // ECMA-262 section 15.7.4.3 function NumberToLocaleString() { - return %_CallFunction(this, NumberToStringJS); + return %_Call(NumberToStringJS, this); } @@ -1767,7 +1767,7 @@ function NewFunctionString(args, function_token) { // If the formal parameters string include ) - an illegal // character - it may make the combined function expression // compile. We avoid this problem by checking for this early on. - if (%_CallFunction(p, ')', StringIndexOf) != -1) { + if (%_Call(StringIndexOf, p, ')') != -1) { throw MakeSyntaxError(kParenthesisInArgString); } // If the formal parameters include an unbalanced block comment, the @@ -1785,7 +1785,7 @@ function FunctionConstructor(arg1) { // length == 1 var global_proxy = %GlobalProxy(FunctionConstructor); // Compile the string in the constructor and not a helper so that errors // appear to come from here. - var func = %_CallFunction(global_proxy, %CompileString(source, true)); + var func = %_Call(%CompileString(source, true), global_proxy); // Set name-should-print-as-anonymous flag on the ShareFunctionInfo and // ensure that |func| uses correct initial map from |new.target| if // it's available. @@ -1816,7 +1816,7 @@ function GetIterator(obj, method) { if (!IS_CALLABLE(method)) { throw MakeTypeError(kNotIterable, obj); } - var iterator = %_CallFunction(obj, method); + var iterator = %_Call(method, obj); if (!IS_SPEC_OBJECT(iterator)) { throw MakeTypeError(kNotAnIterator, iterator); } diff --git a/src/runtime/runtime-function.cc b/src/runtime/runtime-function.cc index d4aba1abdc..16e6149e7c 100644 --- a/src/runtime/runtime-function.cc +++ b/src/runtime/runtime-function.cc @@ -589,39 +589,6 @@ RUNTIME_FUNCTION(Runtime_ConvertReceiver) { } -// TODO(bmeurer): Kill %_CallFunction ASAP as it is almost never used -// correctly because of the weird semantics underneath. -RUNTIME_FUNCTION(Runtime_CallFunction) { - HandleScope scope(isolate); - DCHECK(args.length() >= 2); - int argc = args.length() - 2; - CONVERT_ARG_CHECKED(JSReceiver, fun, argc + 1); - Object* receiver = args[0]; - - // If there are too many arguments, allocate argv via malloc. - const int argv_small_size = 10; - Handle argv_small_buffer[argv_small_size]; - base::SmartArrayPointer> argv_large_buffer; - Handle* argv = argv_small_buffer; - if (argc > argv_small_size) { - argv = new Handle[argc]; - if (argv == NULL) return isolate->StackOverflow(); - argv_large_buffer = base::SmartArrayPointer>(argv); - } - - for (int i = 0; i < argc; ++i) { - argv[i] = Handle(args[1 + i], isolate); - } - - Handle hfun(fun); - Handle hreceiver(receiver, isolate); - Handle result; - ASSIGN_RETURN_FAILURE_ON_EXCEPTION( - isolate, result, Execution::Call(isolate, hfun, hreceiver, argc, argv)); - return *result; -} - - RUNTIME_FUNCTION(Runtime_IsConstructCall) { SealHandleScope shs(isolate); DCHECK(args.length() == 0); diff --git a/src/runtime/runtime.h b/src/runtime/runtime.h index 872cf1194d..92b66b7715 100644 --- a/src/runtime/runtime.h +++ b/src/runtime/runtime.h @@ -261,7 +261,6 @@ namespace internal { F(Apply, 5, 1) \ F(GetOriginalConstructor, 0, 1) \ F(ConvertReceiver, 1, 1) \ - F(CallFunction, -1 /* receiver + n args + function */, 1) \ F(IsConstructCall, 0, 1) \ F(IsFunction, 1, 1) diff --git a/test/cctest/compiler/test-run-intrinsics.cc b/test/cctest/compiler/test-run-intrinsics.cc index 8b72a8b564..fd2b3e6d16 100644 --- a/test/cctest/compiler/test-run-intrinsics.cc +++ b/test/cctest/compiler/test-run-intrinsics.cc @@ -14,9 +14,8 @@ namespace compiler { uint32_t flags = CompilationInfo::kInliningEnabled; -TEST(CallFunction) { - FunctionTester T("(function(a,b) { return %_CallFunction(a, 1, 2, 3, b); })", - flags); +TEST(Call) { + FunctionTester T("(function(a,b) { return %_Call(b, a, 1, 2, 3); })", flags); CompileRun("function f(a,b,c) { return a + b + c + this.d; }"); T.CheckCall(T.Val(129), T.NewObject("({d:123})"), T.NewObject("f")); diff --git a/test/mjsunit/call-runtime-tail.js b/test/mjsunit/call-runtime-tail.js index 2b38b339e2..9f404a8089 100644 --- a/test/mjsunit/call-runtime-tail.js +++ b/test/mjsunit/call-runtime-tail.js @@ -16,7 +16,7 @@ tailee1 = function() { if (count1-- == 0) { return this; } - return %_CallFunction(this, tailee1); + return %_Call(tailee1, this); }; %OptimizeFunctionOnNextCall(tailee1); @@ -33,7 +33,7 @@ tailee2 = function(px) { if ((count2 | 0) === 0) { return this; } - return %_CallFunction(this, px, tailee2); + return %_Call(tailee2, this, px); }; %OptimizeFunctionOnNextCall(tailee2); @@ -47,7 +47,7 @@ tailee3 = function(px) { if (count3-- == 0) { return this; } - return %_CallFunction(px, this, tailee3); + return %_Call(tailee3, px, this); }; %OptimizeFunctionOnNextCall(tailee3); @@ -61,7 +61,7 @@ tailee4 = function(px) { if (count4-- == 0) { return this; } - return %_CallFunction(this, px, undefined, tailee4); + return %_Call(tailee4, this, px, undefined); }; %OptimizeFunctionOnNextCall(tailee4); @@ -75,7 +75,7 @@ tailee5 = function(px) { if (count5-- == 0) { return this; } - return %_CallFunction(this, tailee5); + return %_Call(tailee5, this); }; %OptimizeFunctionOnNextCall(tailee5); diff --git a/test/mjsunit/compiler/regress-lazy-deopt.js b/test/mjsunit/compiler/regress-lazy-deopt.js index d1c3d01dc6..766220763b 100644 --- a/test/mjsunit/compiler/regress-lazy-deopt.js +++ b/test/mjsunit/compiler/regress-lazy-deopt.js @@ -27,7 +27,7 @@ // Flags: --allow-natives-syntax -// Test lazy deoptimization after CallFunctionStub. +// Test lazy deoptimization after Call builtin. function foo() { return 1; } @@ -37,7 +37,7 @@ function f(x, y) { %DeoptimizeFunction(f); return 1; } - a[0] = %_CallFunction(null, x - 1, f); + a[0] = %_Call(f, null, x - 1); return x >> a[0]; } diff --git a/test/mjsunit/harmony/proxies-function.js b/test/mjsunit/harmony/proxies-function.js index 3c36a4f204..113ea79f46 100644 --- a/test/mjsunit/harmony/proxies-function.js +++ b/test/mjsunit/harmony/proxies-function.js @@ -118,10 +118,10 @@ function TestCall(isStrict, callTrap) { assertEquals(42, %Apply(f, null, [11, 31], 0, 2)) assertSame(isStrict ? null : global_object, receiver) receiver = 333 - assertEquals(42, %_CallFunction(o, 11, 31, f)) + assertEquals(42, %_Call(f, o, 11, 31)) assertSame(o, receiver) receiver = 333 - assertEquals(42, %_CallFunction(null, 11, 31, f)) + assertEquals(42, %_Call(f, null, 11, 31)) assertSame(isStrict ? null : global_object, receiver) var ff = Function.prototype.bind.call(f, o, 12) @@ -148,10 +148,10 @@ function TestCall(isStrict, callTrap) { assertEquals(24, %Apply(ff, {}, [12, 13], 0, 2)) assertSame(o, receiver) receiver = 333 - assertEquals(34, %_CallFunction({}, 22, ff)) + assertEquals(34, %_Call(ff, {}, 22)) assertSame(o, receiver) receiver = 333 - assertEquals(34, %_CallFunction({}, 22, 3, ff)) + assertEquals(34, %_Call(ff, {}, 22, 3)) assertSame(o, receiver) var fff = Function.prototype.bind.call(ff, o, 30) @@ -181,10 +181,10 @@ function TestCall(isStrict, callTrap) { assertEquals(42, %Apply(fff, {}, [12, 13], 0, 2)) assertSame(o, receiver) receiver = 333 - assertEquals(42, %_CallFunction({}, fff)) + assertEquals(42, %_Call(fff, {})) assertSame(o, receiver) receiver = 333 - assertEquals(42, %_CallFunction({}, 3, 4, 5, fff)) + assertEquals(42, %_Call(fff, {}, 3, 4, 5)) assertSame(o, receiver) var f = CreateFrozen({}, callTrap) @@ -217,7 +217,7 @@ function TestCall(isStrict, callTrap) { assertEquals(27, %Apply(f, o, [12, 13, 14], 1, 2)) assertSame(o, receiver) receiver = 333 - assertEquals(42, %_CallFunction(o, 18, 24, f)) + assertEquals(42, %_Call(f, o, 18, 24)) assertSame(o, receiver) } @@ -284,8 +284,8 @@ function TestCallThrow(callTrap) { assertThrows(function(){ %Call(f, {}, 1, 2) }, "myexn") assertThrows(function(){ %Apply({}, f, [], 3, 0) }, "myexn") assertThrows(function(){ %Apply({}, f, [3, 4], 0, 1) }, "myexn") - assertThrows(function(){ %_CallFunction({}, f) }, "myexn") - assertThrows(function(){ %_CallFunction({}, 1, 2, f) }, "myexn") + assertThrows(function(){ %_Call(f, {}) }, "myexn") + assertThrows(function(){ %_Call(f, {}, 1, 2) }, "myexn") var f = CreateFrozen({}, callTrap) assertThrows(function(){ f(11) }, "myexn") @@ -297,8 +297,8 @@ function TestCallThrow(callTrap) { assertThrows(function(){ %Call(f, {}, 1, 2) }, "myexn") assertThrows(function(){ %Apply({}, f, [], 3, 0) }, "myexn") assertThrows(function(){ %Apply({}, f, [3, 4], 0, 1) }, "myexn") - assertThrows(function(){ %_CallFunction({}, f) }, "myexn") - assertThrows(function(){ %_CallFunction({}, 1, 2, f) }, "myexn") + assertThrows(function(){ %_Call(f, {}) }, "myexn") + assertThrows(function(){ %_Call(f, {}, 1, 2) }, "myexn") } TestCallThrow(function() { throw "myexn" }) @@ -697,7 +697,7 @@ function TestCalls() { function(f, x, y, o) { return f.apply(o, [x, y]) }, function(f, x, y, o) { return Function.prototype.call.call(f, o, x, y) }, function(f, x, y, o) { return Function.prototype.apply.call(f, o, [x, y]) }, - function(f, x, y, o) { return %_CallFunction(o, x, y, f) }, + function(f, x, y, o) { return %_Call(f, o, x, y) }, function(f, x, y, o) { return %Call(f, o, x, y) }, function(f, x, y, o) { return %Apply(f, o, [null, x, y, null], 1, 2) }, function(f, x, y, o) { return %Apply(f, o, arguments, 2, 2) }, diff --git a/test/mjsunit/regress/call-function-in-effect-context-deopt.js b/test/mjsunit/regress/call-function-in-effect-context-deopt.js index 704af744d2..72d3938511 100644 --- a/test/mjsunit/regress/call-function-in-effect-context-deopt.js +++ b/test/mjsunit/regress/call-function-in-effect-context-deopt.js @@ -29,7 +29,7 @@ function f(deopt, osr) { var result = "result"; - %_CallFunction(0, 0, function() {}); + %_Call(function() {}, 0, 0); var dummy = deopt + 0; for (var i = 0; osr && i < 2; i++) %OptimizeOsr(); return result; diff --git a/test/mjsunit/regress/regress-2285.js b/test/mjsunit/regress/regress-2285.js deleted file mode 100644 index a0d628df93..0000000000 --- a/test/mjsunit/regress/regress-2285.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2012 the V8 project authors. All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials provided -// with the distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived -// from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Flags: --allow-natives-syntax - -assertThrows(function() { %_CallFunction(null, 0, ""); }); -assertThrows(function() { %_CallFunction(null, 0, 1); }); diff --git a/test/mjsunit/regress/regress-3183.js b/test/mjsunit/regress/regress-3183.js index 0c915b0aec..4551621e65 100644 --- a/test/mjsunit/regress/regress-3183.js +++ b/test/mjsunit/regress/regress-3183.js @@ -83,7 +83,7 @@ } function bar(x, deopt) { - %_CallFunction(null, 'push', [x][0], ((deopt + 0), 1), f1); + %_Call(f1, null, 'push', [x][0], ((deopt + 0), 1)); } function foo() { return bar(arguments[0], arguments[1]); } diff --git a/test/mjsunit/regress/regress-crbug-405922.js b/test/mjsunit/regress/regress-crbug-405922.js index 9f76a862db..a38ac86912 100644 --- a/test/mjsunit/regress/regress-crbug-405922.js +++ b/test/mjsunit/regress/regress-crbug-405922.js @@ -18,7 +18,7 @@ function listener(event, exec_state, event_data, data) { Debug.setListener(listener); function f(x) { - if (x > 0) %_CallFunction(null, x-1, f); + if (x > 0) %_Call(f, null, x-1); } debugger; diff --git a/test/mjsunit/strong/function-arity.js b/test/mjsunit/strong/function-arity.js index 55e0600b53..5ead236171 100644 --- a/test/mjsunit/strong/function-arity.js +++ b/test/mjsunit/strong/function-arity.js @@ -70,8 +70,7 @@ function generateSpread(n) { `f.call(undefined, ${generateSpread(argumentCount)})`, `f.apply(undefined, [${generateArguments(argumentCount)}])`, `f.bind(undefined)(${generateArguments(argumentCount)})`, - `%_CallFunction(${generateArguments(argumentCount, 'undefined')}, - f)`, + `%_Call(f, ${generateArguments(argumentCount, 'undefined')})`, `%Call(f, ${generateArguments(argumentCount, 'undefined')})`, `%Apply(f, undefined, [${generateArguments(argumentCount)}], 0, ${argumentCount})`, @@ -134,7 +133,7 @@ function generateSpread(n) { `o.m.call(o, ${generateSpread(argumentCount)})`, `o.m.apply(o, [${generateArguments(argumentCount)}])`, `o.m.bind(o)(${generateArguments(argumentCount)})`, - `%_CallFunction(${generateArguments(argumentCount, 'o')}, o.m)`, + `%_Call(o.m, ${generateArguments(argumentCount, 'o')})`, `%Call(o.m, ${generateArguments(argumentCount, 'o')})`, `%Apply(o.m, o, [${generateArguments(argumentCount)}], 0, ${argumentCount})`,