Commit e06c7197 authored by Igor Sheludko's avatar Igor Sheludko Committed by Commit Bot

[builtins] Define interface descriptors for builtins with JSFunction linkage.

This is a first bulk of changes.

BUG=v8:6116

Change-Id: I9308129bd032c0bf5b60c8e0413ee2cb710891ea
Reviewed-on: https://chromium-review.googlesource.com/456556
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#43930}
parent 3e0aabb6
......@@ -1049,6 +1049,7 @@ v8_source_set("v8_base") {
"src/builtins/builtins-dataview.cc",
"src/builtins/builtins-date.cc",
"src/builtins/builtins-debug.cc",
"src/builtins/builtins-descriptors.h",
"src/builtins/builtins-error.cc",
"src/builtins/builtins-forin.h",
"src/builtins/builtins-function.cc",
......
......@@ -22,6 +22,8 @@ class ArrayBuiltinCodeStubAssembler : public CodeStubAssembler {
const char* name, const BuiltinResultGenerator& generator,
const CallResultProcessor& processor,
const Callable& slow_case_continuation) {
// TODO(ishell): use constants from Descriptor once the JSFunction linkage
// arguments are reordered.
Node* receiver = Parameter(IteratingArrayBuiltinDescriptor::kReceiver);
Node* callbackfn = Parameter(IteratingArrayBuiltinDescriptor::kCallback);
Node* this_arg = Parameter(IteratingArrayBuiltinDescriptor::kThisArg);
......@@ -108,6 +110,8 @@ class ArrayBuiltinCodeStubAssembler : public CodeStubAssembler {
void GenerateIteratingArrayBuiltinLoopContinuation(
const CallResultProcessor& processor) {
// TODO(ishell): use constants from Descriptor once the JSFunction linkage
// arguments are reordered.
Node* callbackfn =
Parameter(IteratingArrayBuiltinLoopContinuationDescriptor::kCallback);
Node* this_arg =
......@@ -318,6 +322,8 @@ TF_BUILTIN(FastArrayPush, CodeStubAssembler) {
Label double_transition(this);
Label runtime(this, Label::kDeferred);
// TODO(ishell): use constants from Descriptor once the JSFunction linkage
// arguments are reordered.
Node* argc = Parameter(BuiltinDescriptor::kArgumentsCount);
Node* context = Parameter(BuiltinDescriptor::kContext);
Node* new_target = Parameter(BuiltinDescriptor::kNewTarget);
......@@ -510,8 +516,8 @@ TF_BUILTIN(ArrayEvery, ArrayBuiltinCodeStubAssembler) {
}
TF_BUILTIN(ArrayIsArray, CodeStubAssembler) {
Node* object = Parameter(1);
Node* context = Parameter(4);
Node* object = Parameter(Descriptor::kArg);
Node* context = Parameter(Descriptor::kContext);
Label call_runtime(this), return_true(this), return_false(this);
......@@ -536,10 +542,10 @@ TF_BUILTIN(ArrayIsArray, CodeStubAssembler) {
}
TF_BUILTIN(ArrayIncludes, CodeStubAssembler) {
Node* const array = Parameter(0);
Node* const search_element = Parameter(1);
Node* const start_from = Parameter(2);
Node* const context = Parameter(3 + 2);
Node* const array = Parameter(Descriptor::kReceiver);
Node* const search_element = Parameter(Descriptor::kSearchElement);
Node* const start_from = Parameter(Descriptor::kFromIndex);
Node* const context = Parameter(Descriptor::kContext);
Variable index_var(this, MachineType::PointerRepresentation());
......@@ -825,10 +831,10 @@ TF_BUILTIN(ArrayIncludes, CodeStubAssembler) {
}
TF_BUILTIN(ArrayIndexOf, CodeStubAssembler) {
Node* array = Parameter(0);
Node* search_element = Parameter(1);
Node* start_from = Parameter(2);
Node* context = Parameter(3 + 2);
Node* array = Parameter(Descriptor::kReceiver);
Node* search_element = Parameter(Descriptor::kSearchElement);
Node* start_from = Parameter(Descriptor::kFromIndex);
Node* context = Parameter(Descriptor::kContext);
Node* intptr_zero = IntPtrConstant(0);
Node* intptr_one = IntPtrConstant(1);
......@@ -1095,10 +1101,8 @@ class ArrayPrototypeIterationAssembler : public CodeStubAssembler {
: CodeStubAssembler(state) {}
protected:
void Generate_ArrayPrototypeIterationMethod(IterationKind iteration_kind) {
Node* receiver = Parameter(0);
Node* context = Parameter(3);
void Generate_ArrayPrototypeIterationMethod(Node* context, Node* receiver,
IterationKind iteration_kind) {
Variable var_array(this, MachineRepresentation::kTagged);
Variable var_map(this, MachineRepresentation::kTagged);
Variable var_type(this, MachineRepresentation::kWord32);
......@@ -1130,23 +1134,32 @@ class ArrayPrototypeIterationAssembler : public CodeStubAssembler {
};
TF_BUILTIN(ArrayPrototypeValues, ArrayPrototypeIterationAssembler) {
Generate_ArrayPrototypeIterationMethod(IterationKind::kValues);
Node* context = Parameter(Descriptor::kContext);
Node* receiver = Parameter(Descriptor::kReceiver);
Generate_ArrayPrototypeIterationMethod(context, receiver,
IterationKind::kValues);
}
TF_BUILTIN(ArrayPrototypeEntries, ArrayPrototypeIterationAssembler) {
Generate_ArrayPrototypeIterationMethod(IterationKind::kEntries);
Node* context = Parameter(Descriptor::kContext);
Node* receiver = Parameter(Descriptor::kReceiver);
Generate_ArrayPrototypeIterationMethod(context, receiver,
IterationKind::kEntries);
}
TF_BUILTIN(ArrayPrototypeKeys, ArrayPrototypeIterationAssembler) {
Generate_ArrayPrototypeIterationMethod(IterationKind::kKeys);
Node* context = Parameter(Descriptor::kContext);
Node* receiver = Parameter(Descriptor::kReceiver);
Generate_ArrayPrototypeIterationMethod(context, receiver,
IterationKind::kKeys);
}
TF_BUILTIN(ArrayIteratorPrototypeNext, CodeStubAssembler) {
Handle<String> operation = factory()->NewStringFromAsciiChecked(
"Array Iterator.prototype.next", TENURED);
Node* iterator = Parameter(0);
Node* context = Parameter(3);
Node* context = Parameter(Descriptor::kContext);
Node* iterator = Parameter(Descriptor::kReceiver);
Variable var_value(this, MachineRepresentation::kTagged);
Variable var_done(this, MachineRepresentation::kTagged);
......
......@@ -71,8 +71,8 @@ void AsyncFunctionBuiltinsAssembler::AsyncFunctionAwaitResumeClosure(
TF_BUILTIN(AsyncFunctionAwaitRejectClosure, AsyncFunctionBuiltinsAssembler) {
CSA_ASSERT_JS_ARGC_EQ(this, 1);
Node* const sentError = Parameter(1);
Node* const context = Parameter(4);
Node* const sentError = Parameter(Descriptor::kSentError);
Node* const context = Parameter(Descriptor::kContext);
AsyncFunctionAwaitResumeClosure(context, sentError,
JSGeneratorObject::kThrow);
......@@ -81,8 +81,8 @@ TF_BUILTIN(AsyncFunctionAwaitRejectClosure, AsyncFunctionBuiltinsAssembler) {
TF_BUILTIN(AsyncFunctionAwaitResolveClosure, AsyncFunctionBuiltinsAssembler) {
CSA_ASSERT_JS_ARGC_EQ(this, 1);
Node* const sentValue = Parameter(1);
Node* const context = Parameter(4);
Node* const sentValue = Parameter(Descriptor::kSentValue);
Node* const context = Parameter(Descriptor::kContext);
AsyncFunctionAwaitResumeClosure(context, sentValue, JSGeneratorObject::kNext);
Return(UndefinedConstant());
......@@ -130,10 +130,10 @@ void AsyncFunctionBuiltinsAssembler::AsyncFunctionAwait(
// prediction indicates that there is a locally surrounding catch block.
TF_BUILTIN(AsyncFunctionAwaitCaught, AsyncFunctionBuiltinsAssembler) {
CSA_ASSERT_JS_ARGC_EQ(this, 3);
Node* const generator = Parameter(1);
Node* const awaited = Parameter(2);
Node* const outer_promise = Parameter(3);
Node* const context = Parameter(6);
Node* const generator = Parameter(Descriptor::kGenerator);
Node* const awaited = Parameter(Descriptor::kAwaited);
Node* const outer_promise = Parameter(Descriptor::kOuterPromise);
Node* const context = Parameter(Descriptor::kContext);
static const bool kIsPredictedAsCaught = true;
......@@ -145,10 +145,10 @@ TF_BUILTIN(AsyncFunctionAwaitCaught, AsyncFunctionBuiltinsAssembler) {
// prediction indicates no locally surrounding catch block.
TF_BUILTIN(AsyncFunctionAwaitUncaught, AsyncFunctionBuiltinsAssembler) {
CSA_ASSERT_JS_ARGC_EQ(this, 3);
Node* const generator = Parameter(1);
Node* const awaited = Parameter(2);
Node* const outer_promise = Parameter(3);
Node* const context = Parameter(6);
Node* const generator = Parameter(Descriptor::kGenerator);
Node* const awaited = Parameter(Descriptor::kAwaited);
Node* const outer_promise = Parameter(Descriptor::kOuterPromise);
Node* const context = Parameter(Descriptor::kContext);
static const bool kIsPredictedAsCaught = false;
......@@ -158,7 +158,7 @@ TF_BUILTIN(AsyncFunctionAwaitUncaught, AsyncFunctionBuiltinsAssembler) {
TF_BUILTIN(AsyncFunctionPromiseCreate, AsyncFunctionBuiltinsAssembler) {
CSA_ASSERT_JS_ARGC_EQ(this, 0);
Node* const context = Parameter(3);
Node* const context = Parameter(Descriptor::kContext);
Node* const promise = AllocateAndInitJSPromise(context);
......@@ -182,8 +182,8 @@ TF_BUILTIN(AsyncFunctionPromiseCreate, AsyncFunctionBuiltinsAssembler) {
TF_BUILTIN(AsyncFunctionPromiseRelease, AsyncFunctionBuiltinsAssembler) {
CSA_ASSERT_JS_ARGC_EQ(this, 1);
Node* const promise = Parameter(1);
Node* const context = Parameter(4);
Node* const promise = Parameter(Descriptor::kPromise);
Node* const context = Parameter(Descriptor::kContext);
Label if_is_debug_active(this, Label::kDeferred);
GotoIf(IsDebugActive(), &if_is_debug_active);
......
......@@ -12,10 +12,10 @@ namespace internal {
// -----------------------------------------------------------------------------
// ES6 section 19.3 Boolean Objects
// ES6 section 19.3.3.2 Boolean.prototype.toString ( )
// ES6 #sec-boolean.prototype.tostring
TF_BUILTIN(BooleanPrototypeToString, CodeStubAssembler) {
Node* receiver = Parameter(0);
Node* context = Parameter(3);
Node* context = Parameter(Descriptor::kContext);
Node* receiver = Parameter(Descriptor::kReceiver);
Node* value = ToThisValue(context, receiver, PrimitiveType::kBoolean,
"Boolean.prototype.toString");
......@@ -23,10 +23,10 @@ TF_BUILTIN(BooleanPrototypeToString, CodeStubAssembler) {
Return(result);
}
// ES6 section 19.3.3.3 Boolean.prototype.valueOf ( )
// ES6 #sec-boolean.prototype.valueof
TF_BUILTIN(BooleanPrototypeValueOf, CodeStubAssembler) {
Node* receiver = Parameter(0);
Node* context = Parameter(3);
Node* context = Parameter(Descriptor::kContext);
Node* receiver = Parameter(Descriptor::kReceiver);
Node* result = ToThisValue(context, receiver, PrimitiveType::kBoolean,
"Boolean.prototype.valueOf");
......
......@@ -18,13 +18,13 @@ class DateBuiltinsAssembler : public CodeStubAssembler {
: CodeStubAssembler(state) {}
protected:
void Generate_DatePrototype_GetField(int field_index);
void Generate_DatePrototype_GetField(Node* context, Node* receiver,
int field_index);
};
void DateBuiltinsAssembler::Generate_DatePrototype_GetField(int field_index) {
Node* receiver = Parameter(0);
Node* context = Parameter(3);
void DateBuiltinsAssembler::Generate_DatePrototype_GetField(Node* context,
Node* receiver,
int field_index) {
Label receiver_not_date(this, Label::kDeferred);
GotoIf(TaggedIsSmi(receiver), &receiver_not_date);
......@@ -68,85 +68,123 @@ void DateBuiltinsAssembler::Generate_DatePrototype_GetField(int field_index) {
}
TF_BUILTIN(DatePrototypeGetDate, DateBuiltinsAssembler) {
Generate_DatePrototype_GetField(JSDate::kDay);
Node* context = Parameter(Descriptor::kContext);
Node* receiver = Parameter(Descriptor::kReceiver);
Generate_DatePrototype_GetField(context, receiver, JSDate::kDay);
}
TF_BUILTIN(DatePrototypeGetDay, DateBuiltinsAssembler) {
Generate_DatePrototype_GetField(JSDate::kWeekday);
Node* context = Parameter(Descriptor::kContext);
Node* receiver = Parameter(Descriptor::kReceiver);
Generate_DatePrototype_GetField(context, receiver, JSDate::kWeekday);
}
TF_BUILTIN(DatePrototypeGetFullYear, DateBuiltinsAssembler) {
Generate_DatePrototype_GetField(JSDate::kYear);
Node* context = Parameter(Descriptor::kContext);
Node* receiver = Parameter(Descriptor::kReceiver);
Generate_DatePrototype_GetField(context, receiver, JSDate::kYear);
}
TF_BUILTIN(DatePrototypeGetHours, DateBuiltinsAssembler) {
Generate_DatePrototype_GetField(JSDate::kHour);
Node* context = Parameter(Descriptor::kContext);
Node* receiver = Parameter(Descriptor::kReceiver);
Generate_DatePrototype_GetField(context, receiver, JSDate::kHour);
}
TF_BUILTIN(DatePrototypeGetMilliseconds, DateBuiltinsAssembler) {
Generate_DatePrototype_GetField(JSDate::kMillisecond);
Node* context = Parameter(Descriptor::kContext);
Node* receiver = Parameter(Descriptor::kReceiver);
Generate_DatePrototype_GetField(context, receiver, JSDate::kMillisecond);
}
TF_BUILTIN(DatePrototypeGetMinutes, DateBuiltinsAssembler) {
Generate_DatePrototype_GetField(JSDate::kMinute);
Node* context = Parameter(Descriptor::kContext);
Node* receiver = Parameter(Descriptor::kReceiver);
Generate_DatePrototype_GetField(context, receiver, JSDate::kMinute);
}
TF_BUILTIN(DatePrototypeGetMonth, DateBuiltinsAssembler) {
Generate_DatePrototype_GetField(JSDate::kMonth);
Node* context = Parameter(Descriptor::kContext);
Node* receiver = Parameter(Descriptor::kReceiver);
Generate_DatePrototype_GetField(context, receiver, JSDate::kMonth);
}
TF_BUILTIN(DatePrototypeGetSeconds, DateBuiltinsAssembler) {
Generate_DatePrototype_GetField(JSDate::kSecond);
Node* context = Parameter(Descriptor::kContext);
Node* receiver = Parameter(Descriptor::kReceiver);
Generate_DatePrototype_GetField(context, receiver, JSDate::kSecond);
}
TF_BUILTIN(DatePrototypeGetTime, DateBuiltinsAssembler) {
Generate_DatePrototype_GetField(JSDate::kDateValue);
Node* context = Parameter(Descriptor::kContext);
Node* receiver = Parameter(Descriptor::kReceiver);
Generate_DatePrototype_GetField(context, receiver, JSDate::kDateValue);
}
TF_BUILTIN(DatePrototypeGetTimezoneOffset, DateBuiltinsAssembler) {
Generate_DatePrototype_GetField(JSDate::kTimezoneOffset);
Node* context = Parameter(Descriptor::kContext);
Node* receiver = Parameter(Descriptor::kReceiver);
Generate_DatePrototype_GetField(context, receiver, JSDate::kTimezoneOffset);
}
TF_BUILTIN(DatePrototypeGetUTCDate, DateBuiltinsAssembler) {
Generate_DatePrototype_GetField(JSDate::kDayUTC);
Node* context = Parameter(Descriptor::kContext);
Node* receiver = Parameter(Descriptor::kReceiver);
Generate_DatePrototype_GetField(context, receiver, JSDate::kDayUTC);
}
TF_BUILTIN(DatePrototypeGetUTCDay, DateBuiltinsAssembler) {
Generate_DatePrototype_GetField(JSDate::kWeekdayUTC);
Node* context = Parameter(Descriptor::kContext);
Node* receiver = Parameter(Descriptor::kReceiver);
Generate_DatePrototype_GetField(context, receiver, JSDate::kWeekdayUTC);
}
TF_BUILTIN(DatePrototypeGetUTCFullYear, DateBuiltinsAssembler) {
Generate_DatePrototype_GetField(JSDate::kYearUTC);
Node* context = Parameter(Descriptor::kContext);
Node* receiver = Parameter(Descriptor::kReceiver);
Generate_DatePrototype_GetField(context, receiver, JSDate::kYearUTC);
}
TF_BUILTIN(DatePrototypeGetUTCHours, DateBuiltinsAssembler) {
Generate_DatePrototype_GetField(JSDate::kHourUTC);
Node* context = Parameter(Descriptor::kContext);
Node* receiver = Parameter(Descriptor::kReceiver);
Generate_DatePrototype_GetField(context, receiver, JSDate::kHourUTC);
}
TF_BUILTIN(DatePrototypeGetUTCMilliseconds, DateBuiltinsAssembler) {
Generate_DatePrototype_GetField(JSDate::kMillisecondUTC);
Node* context = Parameter(Descriptor::kContext);
Node* receiver = Parameter(Descriptor::kReceiver);
Generate_DatePrototype_GetField(context, receiver, JSDate::kMillisecondUTC);
}
TF_BUILTIN(DatePrototypeGetUTCMinutes, DateBuiltinsAssembler) {
Generate_DatePrototype_GetField(JSDate::kMinuteUTC);
Node* context = Parameter(Descriptor::kContext);
Node* receiver = Parameter(Descriptor::kReceiver);
Generate_DatePrototype_GetField(context, receiver, JSDate::kMinuteUTC);
}
TF_BUILTIN(DatePrototypeGetUTCMonth, DateBuiltinsAssembler) {
Generate_DatePrototype_GetField(JSDate::kMonthUTC);
Node* context = Parameter(Descriptor::kContext);
Node* receiver = Parameter(Descriptor::kReceiver);
Generate_DatePrototype_GetField(context, receiver, JSDate::kMonthUTC);
}
TF_BUILTIN(DatePrototypeGetUTCSeconds, DateBuiltinsAssembler) {
Generate_DatePrototype_GetField(JSDate::kSecondUTC);
Node* context = Parameter(Descriptor::kContext);
Node* receiver = Parameter(Descriptor::kReceiver);
Generate_DatePrototype_GetField(context, receiver, JSDate::kSecondUTC);
}
TF_BUILTIN(DatePrototypeValueOf, DateBuiltinsAssembler) {
Generate_DatePrototype_GetField(JSDate::kDateValue);
Node* context = Parameter(Descriptor::kContext);
Node* receiver = Parameter(Descriptor::kReceiver);
Generate_DatePrototype_GetField(context, receiver, JSDate::kDateValue);
}
TF_BUILTIN(DatePrototypeToPrimitive, CodeStubAssembler) {
Node* receiver = Parameter(0);
Node* hint = Parameter(1);
Node* context = Parameter(4);
Node* context = Parameter(Descriptor::kContext);
Node* receiver = Parameter(Descriptor::kReceiver);
Node* hint = Parameter(Descriptor::kHint);
// Check if the {receiver} is actually a JSReceiver.
Label receiver_is_invalid(this, Label::kDeferred);
......
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_BUILTINS_BUILTINS_DESCRIPTORS_H_
#define V8_BUILTINS_BUILTINS_DESCRIPTORS_H_
#include "src/builtins/builtins.h"
#include "src/interface-descriptors.h"
namespace v8 {
namespace internal {
// Define interface descriptors for builtins with JS linkage.
#define DEFINE_TFJ_INTERFACE_DESCRIPTOR(Name, Argc, ...) \
struct Builtin_##Name##_InterfaceDescriptor { \
enum ParameterIndices { \
kReceiver, \
##__VA_ARGS__, \
kNewTarget, \
kActualArgumentsCount, \
kContext, \
kParameterCount, \
}; \
};
// Define interface descriptors for builtins with StubCall linkage.
#define DEFINE_TFS_INTERFACE_DESCRIPTOR(Name, Kind, Extra, \
InterfaceDescriptor, result_size) \
typedef InterfaceDescriptor##Descriptor Builtin_##Name##_InterfaceDescriptor;
BUILTIN_LIST(IGNORE_BUILTIN, IGNORE_BUILTIN, DEFINE_TFJ_INTERFACE_DESCRIPTOR,
DEFINE_TFS_INTERFACE_DESCRIPTOR, IGNORE_BUILTIN, IGNORE_BUILTIN,
IGNORE_BUILTIN)
#undef DEFINE_TFJ_INTERFACE_DESCRIPTOR
} // namespace internal
} // namespace v8
#endif // V8_BUILTINS_BUILTINS_DESCRIPTORS_H_
......@@ -12,6 +12,8 @@ namespace internal {
TF_BUILTIN(FastFunctionPrototypeBind, CodeStubAssembler) {
Label slow(this);
// TODO(ishell): use constants from Descriptor once the JSFunction linkage
// arguments are reordered.
Node* argc = Parameter(BuiltinDescriptor::kArgumentsCount);
Node* context = Parameter(BuiltinDescriptor::kContext);
Node* new_target = Parameter(BuiltinDescriptor::kNewTarget);
......@@ -165,11 +167,11 @@ TF_BUILTIN(FastFunctionPrototypeBind, CodeStubAssembler) {
new_target, argc);
}
// ES6 section 19.2.3.6 Function.prototype [ @@hasInstance ] ( V )
// ES6 #sec-function.prototype-@@hasinstance
TF_BUILTIN(FunctionPrototypeHasInstance, CodeStubAssembler) {
Node* f = Parameter(0);
Node* v = Parameter(1);
Node* context = Parameter(4);
Node* context = Parameter(Descriptor::kContext);
Node* f = Parameter(Descriptor::kReceiver);
Node* v = Parameter(Descriptor::kV);
Node* result = OrdinaryHasInstance(context, f, v);
Return(result);
}
......
......@@ -18,15 +18,14 @@ class GeneratorBuiltinsAssembler : public CodeStubAssembler {
: CodeStubAssembler(state) {}
protected:
void GeneratorPrototypeResume(JSGeneratorObject::ResumeMode resume_mode,
void GeneratorPrototypeResume(Node* receiver, Node* value, Node* context,
JSGeneratorObject::ResumeMode resume_mode,
char const* const method_name);
};
void GeneratorBuiltinsAssembler::GeneratorPrototypeResume(
Node* receiver, Node* value, Node* context,
JSGeneratorObject::ResumeMode resume_mode, char const* const method_name) {
Node* receiver = Parameter(0);
Node* value = Parameter(1);
Node* context = Parameter(4);
Node* closed = SmiConstant(JSGeneratorObject::kGeneratorClosed);
// Check if the {receiver} is actually a JSGeneratorObject.
......@@ -92,21 +91,31 @@ void GeneratorBuiltinsAssembler::GeneratorPrototypeResume(
}
}
// ES6 section 25.3.1.2 Generator.prototype.next ( value )
// ES6 #sec-generator.prototype.next
TF_BUILTIN(GeneratorPrototypeNext, GeneratorBuiltinsAssembler) {
GeneratorPrototypeResume(JSGeneratorObject::kNext,
Node* receiver = Parameter(Descriptor::kReceiver);
Node* value = Parameter(Descriptor::kValue);
Node* context = Parameter(Descriptor::kContext);
GeneratorPrototypeResume(receiver, value, context, JSGeneratorObject::kNext,
"[Generator].prototype.next");
}
// ES6 section 25.3.1.3 Generator.prototype.return ( value )
// ES6 #sec-generator.prototype.return
TF_BUILTIN(GeneratorPrototypeReturn, GeneratorBuiltinsAssembler) {
GeneratorPrototypeResume(JSGeneratorObject::kReturn,
Node* receiver = Parameter(Descriptor::kReceiver);
Node* value = Parameter(Descriptor::kValue);
Node* context = Parameter(Descriptor::kContext);
GeneratorPrototypeResume(receiver, value, context, JSGeneratorObject::kReturn,
"[Generator].prototype.return");
}
// ES6 section 25.3.1.4 Generator.prototype.throw ( exception )
// ES6 #sec-generator.prototype.throw
TF_BUILTIN(GeneratorPrototypeThrow, GeneratorBuiltinsAssembler) {
GeneratorPrototypeResume(JSGeneratorObject::kThrow,
Node* receiver = Parameter(Descriptor::kReceiver);
Node* exception = Parameter(Descriptor::kException);
Node* context = Parameter(Descriptor::kContext);
GeneratorPrototypeResume(receiver, exception, context,
JSGeneratorObject::kThrow,
"[Generator].prototype.throw");
}
......
......@@ -9,16 +9,16 @@
namespace v8 {
namespace internal {
// ES6 section 18.2.2 isFinite ( number )
// ES #sec-isfinite-number
TF_BUILTIN(GlobalIsFinite, CodeStubAssembler) {
Node* context = Parameter(4);
Node* context = Parameter(Descriptor::kContext);
Label return_true(this), return_false(this);
// We might need to loop once for ToNumber conversion.
Variable var_num(this, MachineRepresentation::kTagged);
Label loop(this, &var_num);
var_num.Bind(Parameter(1));
var_num.Bind(Parameter(Descriptor::kNumber));
Goto(&loop);
Bind(&loop);
{
......@@ -57,16 +57,16 @@ TF_BUILTIN(GlobalIsFinite, CodeStubAssembler) {
Return(BooleanConstant(false));
}
// ES6 section 18.2.3 isNaN ( number )
// ES6 #sec-isnan-number
TF_BUILTIN(GlobalIsNaN, CodeStubAssembler) {
Node* context = Parameter(4);
Node* context = Parameter(Descriptor::kContext);
Label return_true(this), return_false(this);
// We might need to loop once for ToNumber conversion.
Variable var_num(this, MachineRepresentation::kTagged);
Label loop(this, &var_num);
var_num.Bind(Parameter(1));
var_num.Bind(Parameter(Descriptor::kNumber));
Goto(&loop);
Bind(&loop);
{
......
......@@ -168,7 +168,9 @@ TF_BUILTIN(NewUnmappedArgumentsElements, CodeStubAssembler) {
}
}
TF_BUILTIN(ReturnReceiver, CodeStubAssembler) { Return(Parameter(0)); }
TF_BUILTIN(ReturnReceiver, CodeStubAssembler) {
Return(Parameter(Descriptor::kReceiver));
}
} // namespace internal
} // namespace v8
......@@ -19,20 +19,22 @@ class MathBuiltinsAssembler : public CodeStubAssembler {
: CodeStubAssembler(state) {}
protected:
void MathRoundingOperation(Node* (CodeStubAssembler::*float64op)(Node*));
void MathUnaryOperation(Node* (CodeStubAssembler::*float64op)(Node*));
void MathRoundingOperation(Node* context, Node* x,
Node* (CodeStubAssembler::*float64op)(Node*));
void MathUnaryOperation(Node* context, Node* x,
Node* (CodeStubAssembler::*float64op)(Node*));
void MathMaxMin(Node* (CodeStubAssembler::*float64op)(Node*, Node*),
double default_val);
};
// ES6 section - 20.2.2.1 Math.abs ( x )
// ES6 #sec-math.abs
TF_BUILTIN(MathAbs, CodeStubAssembler) {
Node* context = Parameter(4);
Node* context = Parameter(Descriptor::kContext);
// We might need to loop once for ToNumber conversion.
Variable var_x(this, MachineRepresentation::kTagged);
Label loop(this, &var_x);
var_x.Bind(Parameter(1));
var_x.Bind(Parameter(Descriptor::kX));
Goto(&loop);
Bind(&loop);
{
......@@ -104,13 +106,10 @@ TF_BUILTIN(MathAbs, CodeStubAssembler) {
}
void MathBuiltinsAssembler::MathRoundingOperation(
Node* (CodeStubAssembler::*float64op)(Node*)) {
Node* context = Parameter(4);
Node* context, Node* x, Node* (CodeStubAssembler::*float64op)(Node*)) {
// We might need to loop once for ToNumber conversion.
Variable var_x(this, MachineRepresentation::kTagged);
Variable var_x(this, MachineRepresentation::kTagged, x);
Label loop(this, &var_x);
var_x.Bind(Parameter(1));
Goto(&loop);
Bind(&loop);
{
......@@ -154,9 +153,7 @@ void MathBuiltinsAssembler::MathRoundingOperation(
}
void MathBuiltinsAssembler::MathUnaryOperation(
Node* (CodeStubAssembler::*float64op)(Node*)) {
Node* x = Parameter(1);
Node* context = Parameter(4);
Node* context, Node* x, Node* (CodeStubAssembler::*float64op)(Node*)) {
Node* x_value = TruncateTaggedToFloat64(context, x);
Node* value = (this->*float64op)(x_value);
Node* result = AllocateHeapNumberWithValue(value);
......@@ -165,6 +162,8 @@ void MathBuiltinsAssembler::MathUnaryOperation(
void MathBuiltinsAssembler::MathMaxMin(
Node* (CodeStubAssembler::*float64op)(Node*, Node*), double default_val) {
// TODO(ishell): use constants from Descriptor once the JSFunction linkage
// arguments are reordered.
Node* argc = Parameter(BuiltinDescriptor::kArgumentsCount);
Node* context = Parameter(BuiltinDescriptor::kContext);
......@@ -175,7 +174,7 @@ void MathBuiltinsAssembler::MathMaxMin(
result.Bind(Float64Constant(default_val));
CodeStubAssembler::VariableList vars({&result}, zone());
arguments.ForEach(vars, [this, float64op, context, &result](Node* arg) {
arguments.ForEach(vars, [=, &result](Node* arg) {
Node* float_value = TruncateTaggedToFloat64(context, arg);
result.Bind((this->*float64op)(result.value(), float_value));
});
......@@ -183,40 +182,53 @@ void MathBuiltinsAssembler::MathMaxMin(
arguments.PopAndReturn(ChangeFloat64ToTagged(result.value()));
}
// ES6 section 20.2.2.2 Math.acos ( x )
// ES6 #sec-math.acos
TF_BUILTIN(MathAcos, MathBuiltinsAssembler) {
MathUnaryOperation(&CodeStubAssembler::Float64Acos);
Node* context = Parameter(Descriptor::kContext);
Node* x = Parameter(Descriptor::kX);
MathUnaryOperation(context, x, &CodeStubAssembler::Float64Acos);
}
// ES6 section 20.2.2.3 Math.acosh ( x )
// ES6 #sec-math.acosh
TF_BUILTIN(MathAcosh, MathBuiltinsAssembler) {
MathUnaryOperation(&CodeStubAssembler::Float64Acosh);
Node* context = Parameter(Descriptor::kContext);
Node* x = Parameter(Descriptor::kX);
MathUnaryOperation(context, x, &CodeStubAssembler::Float64Acosh);
}
// ES6 section 20.2.2.4 Math.asin ( x )
// ES6 #sec-math.asin
TF_BUILTIN(MathAsin, MathBuiltinsAssembler) {
MathUnaryOperation(&CodeStubAssembler::Float64Asin);
Node* context = Parameter(Descriptor::kContext);
Node* x = Parameter(Descriptor::kX);
MathUnaryOperation(context, x, &CodeStubAssembler::Float64Asin);
}
// ES6 section 20.2.2.5 Math.asinh ( x )
// ES6 #sec-math.asinh
TF_BUILTIN(MathAsinh, MathBuiltinsAssembler) {
MathUnaryOperation(&CodeStubAssembler::Float64Asinh);
Node* context = Parameter(Descriptor::kContext);
Node* x = Parameter(Descriptor::kX);
MathUnaryOperation(context, x, &CodeStubAssembler::Float64Asinh);
}
// ES6 section 20.2.2.6 Math.atan ( x )
// ES6 #sec-math.atan
TF_BUILTIN(MathAtan, MathBuiltinsAssembler) {
MathUnaryOperation(&CodeStubAssembler::Float64Atan);
Node* context = Parameter(Descriptor::kContext);
Node* x = Parameter(Descriptor::kX);
MathUnaryOperation(context, x, &CodeStubAssembler::Float64Atan);
}
// ES6 section 20.2.2.7 Math.atanh ( x )
// ES6 #sec-math.atanh
TF_BUILTIN(MathAtanh, MathBuiltinsAssembler) {
MathUnaryOperation(&CodeStubAssembler::Float64Atanh);
Node* context = Parameter(Descriptor::kContext);
Node* x = Parameter(Descriptor::kX);
MathUnaryOperation(context, x, &CodeStubAssembler::Float64Atanh);
}
// ES6 section 20.2.2.8 Math.atan2 ( y, x )
// ES6 #sec-math.atan2
TF_BUILTIN(MathAtan2, CodeStubAssembler) {
Node* y = Parameter(1);
Node* x = Parameter(2);
Node* context = Parameter(5);
Node* context = Parameter(Descriptor::kContext);
Node* y = Parameter(Descriptor::kY);
Node* x = Parameter(Descriptor::kX);
Node* y_value = TruncateTaggedToFloat64(context, y);
Node* x_value = TruncateTaggedToFloat64(context, x);
......@@ -225,17 +237,21 @@ TF_BUILTIN(MathAtan2, CodeStubAssembler) {
Return(result);
}
// ES6 section 20.2.2.10 Math.ceil ( x )
// ES6 #sec-math.ceil
TF_BUILTIN(MathCeil, MathBuiltinsAssembler) {
MathRoundingOperation(&CodeStubAssembler::Float64Ceil);
Node* context = Parameter(Descriptor::kContext);
Node* x = Parameter(Descriptor::kX);
MathRoundingOperation(context, x, &CodeStubAssembler::Float64Ceil);
}
// ES6 section 20.2.2.9 Math.cbrt ( x )
// ES6 #sec-math.cbrt
TF_BUILTIN(MathCbrt, MathBuiltinsAssembler) {
MathUnaryOperation(&CodeStubAssembler::Float64Cbrt);
Node* context = Parameter(Descriptor::kContext);
Node* x = Parameter(Descriptor::kX);
MathUnaryOperation(context, x, &CodeStubAssembler::Float64Cbrt);
}
// ES6 section 20.2.2.11 Math.clz32 ( x )
// ES6 #sec-math.clz32
TF_BUILTIN(MathClz32, CodeStubAssembler) {
Node* context = Parameter(4);
......@@ -295,35 +311,45 @@ TF_BUILTIN(MathClz32, CodeStubAssembler) {
}
}
// ES6 section 20.2.2.12 Math.cos ( x )
// ES6 #sec-math.cos
TF_BUILTIN(MathCos, MathBuiltinsAssembler) {
MathUnaryOperation(&CodeStubAssembler::Float64Cos);
Node* context = Parameter(Descriptor::kContext);
Node* x = Parameter(Descriptor::kX);
MathUnaryOperation(context, x, &CodeStubAssembler::Float64Cos);
}
// ES6 section 20.2.2.13 Math.cosh ( x )
// ES6 #sec-math.cosh
TF_BUILTIN(MathCosh, MathBuiltinsAssembler) {
MathUnaryOperation(&CodeStubAssembler::Float64Cosh);
Node* context = Parameter(Descriptor::kContext);
Node* x = Parameter(Descriptor::kX);
MathUnaryOperation(context, x, &CodeStubAssembler::Float64Cosh);
}
// ES6 section 20.2.2.14 Math.exp ( x )
// ES6 #sec-math.exp
TF_BUILTIN(MathExp, MathBuiltinsAssembler) {
MathUnaryOperation(&CodeStubAssembler::Float64Exp);
Node* context = Parameter(Descriptor::kContext);
Node* x = Parameter(Descriptor::kX);
MathUnaryOperation(context, x, &CodeStubAssembler::Float64Exp);
}
// ES6 section 20.2.2.15 Math.expm1 ( x )
// ES6 #sec-math.expm1
TF_BUILTIN(MathExpm1, MathBuiltinsAssembler) {
MathUnaryOperation(&CodeStubAssembler::Float64Expm1);
Node* context = Parameter(Descriptor::kContext);
Node* x = Parameter(Descriptor::kX);
MathUnaryOperation(context, x, &CodeStubAssembler::Float64Expm1);
}
// ES6 section 20.2.2.16 Math.floor ( x )
// ES6 #sec-math.floor
TF_BUILTIN(MathFloor, MathBuiltinsAssembler) {
MathRoundingOperation(&CodeStubAssembler::Float64Floor);
Node* context = Parameter(Descriptor::kContext);
Node* x = Parameter(Descriptor::kX);
MathRoundingOperation(context, x, &CodeStubAssembler::Float64Floor);
}
// ES6 section 20.2.2.17 Math.fround ( x )
// ES6 #sec-math.fround
TF_BUILTIN(MathFround, CodeStubAssembler) {
Node* x = Parameter(1);
Node* context = Parameter(4);
Node* context = Parameter(Descriptor::kContext);
Node* x = Parameter(Descriptor::kX);
Node* x_value = TruncateTaggedToFloat64(context, x);
Node* value32 = TruncateFloat64ToFloat32(x_value);
Node* value = ChangeFloat32ToFloat64(value32);
......@@ -331,11 +357,11 @@ TF_BUILTIN(MathFround, CodeStubAssembler) {
Return(result);
}
// ES6 section 20.2.2.19 Math.imul ( x, y )
// ES6 #sec-math.imul
TF_BUILTIN(MathImul, CodeStubAssembler) {
Node* x = Parameter(1);
Node* y = Parameter(2);
Node* context = Parameter(5);
Node* context = Parameter(Descriptor::kContext);
Node* x = Parameter(Descriptor::kX);
Node* y = Parameter(Descriptor::kY);
Node* x_value = TruncateTaggedToWord32(context, x);
Node* y_value = TruncateTaggedToWord32(context, y);
Node* value = Int32Mul(x_value, y_value);
......@@ -343,31 +369,39 @@ TF_BUILTIN(MathImul, CodeStubAssembler) {
Return(result);
}
// ES6 section 20.2.2.20 Math.log ( x )
// ES6 #sec-math.log
TF_BUILTIN(MathLog, MathBuiltinsAssembler) {
MathUnaryOperation(&CodeStubAssembler::Float64Log);
Node* context = Parameter(Descriptor::kContext);
Node* x = Parameter(Descriptor::kX);
MathUnaryOperation(context, x, &CodeStubAssembler::Float64Log);
}
// ES6 section 20.2.2.21 Math.log1p ( x )
// ES6 #sec-math.log1p
TF_BUILTIN(MathLog1p, MathBuiltinsAssembler) {
MathUnaryOperation(&CodeStubAssembler::Float64Log1p);
Node* context = Parameter(Descriptor::kContext);
Node* x = Parameter(Descriptor::kX);
MathUnaryOperation(context, x, &CodeStubAssembler::Float64Log1p);
}
// ES6 section 20.2.2.22 Math.log10 ( x )
// ES6 #sec-math.log10
TF_BUILTIN(MathLog10, MathBuiltinsAssembler) {
MathUnaryOperation(&CodeStubAssembler::Float64Log10);
Node* context = Parameter(Descriptor::kContext);
Node* x = Parameter(Descriptor::kX);
MathUnaryOperation(context, x, &CodeStubAssembler::Float64Log10);
}
// ES6 section 20.2.2.23 Math.log2 ( x )
// ES6 #sec-math.log2
TF_BUILTIN(MathLog2, MathBuiltinsAssembler) {
MathUnaryOperation(&CodeStubAssembler::Float64Log2);
Node* context = Parameter(Descriptor::kContext);
Node* x = Parameter(Descriptor::kX);
MathUnaryOperation(context, x, &CodeStubAssembler::Float64Log2);
}
// ES6 section 20.2.2.26 Math.pow ( x, y )
// ES6 #sec-math.pow
TF_BUILTIN(MathPow, CodeStubAssembler) {
Node* x = Parameter(1);
Node* y = Parameter(2);
Node* context = Parameter(5);
Node* context = Parameter(Descriptor::kContext);
Node* x = Parameter(Descriptor::kBase);
Node* y = Parameter(Descriptor::kExponent);
Node* x_value = TruncateTaggedToFloat64(context, x);
Node* y_value = TruncateTaggedToFloat64(context, y);
Node* value = Float64Pow(x_value, y_value);
......@@ -375,9 +409,9 @@ TF_BUILTIN(MathPow, CodeStubAssembler) {
Return(result);
}
// ES6 section 20.2.2.27 Math.random ( )
// ES6 #sec-math.random
TF_BUILTIN(MathRandom, CodeStubAssembler) {
Node* context = Parameter(3);
Node* context = Parameter(Descriptor::kContext);
Node* native_context = LoadNativeContext(context);
// Load cache index.
......@@ -407,16 +441,18 @@ TF_BUILTIN(MathRandom, CodeStubAssembler) {
Return(AllocateHeapNumberWithValue(random));
}
// ES6 section 20.2.2.28 Math.round ( x )
// ES6 #sec-math.round
TF_BUILTIN(MathRound, MathBuiltinsAssembler) {
MathRoundingOperation(&CodeStubAssembler::Float64Round);
Node* context = Parameter(Descriptor::kContext);
Node* x = Parameter(Descriptor::kX);
MathRoundingOperation(context, x, &CodeStubAssembler::Float64Round);
}
// ES6 section 20.2.2.29 Math.sign ( x )
// ES6 #sec-math.sign
TF_BUILTIN(MathSign, CodeStubAssembler) {
// Convert the {x} value to a Number.
Node* x = Parameter(1);
Node* context = Parameter(4);
Node* context = Parameter(Descriptor::kContext);
Node* x = Parameter(Descriptor::kX);
Node* x_value = TruncateTaggedToFloat64(context, x);
// Return -1 if {x} is negative, 1 if {x} is positive, or {x} itself.
......@@ -432,42 +468,54 @@ TF_BUILTIN(MathSign, CodeStubAssembler) {
Return(SmiConstant(Smi::FromInt(1)));
}
// ES6 section 20.2.2.30 Math.sin ( x )
// ES6 #sec-math.sin
TF_BUILTIN(MathSin, MathBuiltinsAssembler) {
MathUnaryOperation(&CodeStubAssembler::Float64Sin);
Node* context = Parameter(Descriptor::kContext);
Node* x = Parameter(Descriptor::kX);
MathUnaryOperation(context, x, &CodeStubAssembler::Float64Sin);
}
// ES6 section 20.2.2.31 Math.sinh ( x )
// ES6 #sec-math.sinh
TF_BUILTIN(MathSinh, MathBuiltinsAssembler) {
MathUnaryOperation(&CodeStubAssembler::Float64Sinh);
Node* context = Parameter(Descriptor::kContext);
Node* x = Parameter(Descriptor::kX);
MathUnaryOperation(context, x, &CodeStubAssembler::Float64Sinh);
}
// ES6 section 20.2.2.32 Math.sqrt ( x )
// ES6 #sec-math.sqrt
TF_BUILTIN(MathSqrt, MathBuiltinsAssembler) {
MathUnaryOperation(&CodeStubAssembler::Float64Sqrt);
Node* context = Parameter(Descriptor::kContext);
Node* x = Parameter(Descriptor::kX);
MathUnaryOperation(context, x, &CodeStubAssembler::Float64Sqrt);
}
// ES6 section 20.2.2.33 Math.tan ( x )
// ES6 #sec-math.tan
TF_BUILTIN(MathTan, MathBuiltinsAssembler) {
MathUnaryOperation(&CodeStubAssembler::Float64Tan);
Node* context = Parameter(Descriptor::kContext);
Node* x = Parameter(Descriptor::kX);
MathUnaryOperation(context, x, &CodeStubAssembler::Float64Tan);
}
// ES6 section 20.2.2.34 Math.tanh ( x )
// ES6 #sec-math.tanh
TF_BUILTIN(MathTanh, MathBuiltinsAssembler) {
MathUnaryOperation(&CodeStubAssembler::Float64Tanh);
Node* context = Parameter(Descriptor::kContext);
Node* x = Parameter(Descriptor::kX);
MathUnaryOperation(context, x, &CodeStubAssembler::Float64Tanh);
}
// ES6 section 20.2.2.35 Math.trunc ( x )
// ES6 #sec-math.trunc
TF_BUILTIN(MathTrunc, MathBuiltinsAssembler) {
MathRoundingOperation(&CodeStubAssembler::Float64Trunc);
Node* context = Parameter(Descriptor::kContext);
Node* x = Parameter(Descriptor::kX);
MathRoundingOperation(context, x, &CodeStubAssembler::Float64Trunc);
}
// ES6 section 20.2.2.24 Math.max ( value1, value2 , ...values )
// ES6 #sec-math.max
TF_BUILTIN(MathMax, MathBuiltinsAssembler) {
MathMaxMin(&CodeStubAssembler::Float64Max, -1.0 * V8_INFINITY);
}
// ES6 section 20.2.2.25 Math.min ( value1, value2 , ...values )
// ES6 #sec-math.min
TF_BUILTIN(MathMin, MathBuiltinsAssembler) {
MathMaxMin(&CodeStubAssembler::Float64Min, V8_INFINITY);
}
......
......@@ -34,7 +34,7 @@ class NumberBuiltinsAssembler : public CodeStubAssembler {
template <Signedness signed_result = kSigned>
void BitwiseShiftOp(std::function<Node*(Node* lhs, Node* shift_count)> body) {
BitwiseOp<signed_result>([this, body](Node* lhs, Node* rhs) {
BitwiseOp<signed_result>([=](Node* lhs, Node* rhs) {
Node* shift_count = Word32And(rhs, Int32Constant(0x1f));
return body(lhs, shift_count);
});
......@@ -49,9 +49,9 @@ class NumberBuiltinsAssembler : public CodeStubAssembler {
}
};
// ES6 section 20.1.2.2 Number.isFinite ( number )
// ES6 #sec-number.isfinite
TF_BUILTIN(NumberIsFinite, CodeStubAssembler) {
Node* number = Parameter(1);
Node* number = Parameter(Descriptor::kNumber);
Label return_true(this), return_false(this);
......@@ -73,9 +73,9 @@ TF_BUILTIN(NumberIsFinite, CodeStubAssembler) {
Return(BooleanConstant(false));
}
// ES6 section 20.1.2.3 Number.isInteger ( number )
// ES6 #sec-number.isinteger
TF_BUILTIN(NumberIsInteger, CodeStubAssembler) {
Node* number = Parameter(1);
Node* number = Parameter(Descriptor::kNumber);
Label return_true(this), return_false(this);
......@@ -102,9 +102,9 @@ TF_BUILTIN(NumberIsInteger, CodeStubAssembler) {
Return(BooleanConstant(false));
}
// ES6 section 20.1.2.4 Number.isNaN ( number )
// ES6 #sec-number.isnan
TF_BUILTIN(NumberIsNaN, CodeStubAssembler) {
Node* number = Parameter(1);
Node* number = Parameter(Descriptor::kNumber);
Label return_true(this), return_false(this);
......@@ -125,9 +125,9 @@ TF_BUILTIN(NumberIsNaN, CodeStubAssembler) {
Return(BooleanConstant(false));
}
// ES6 section 20.1.2.5 Number.isSafeInteger ( number )
// ES6 #sec-number.issafeinteger
TF_BUILTIN(NumberIsSafeInteger, CodeStubAssembler) {
Node* number = Parameter(1);
Node* number = Parameter(Descriptor::kNumber);
Label return_true(this), return_false(this);
......@@ -160,14 +160,14 @@ TF_BUILTIN(NumberIsSafeInteger, CodeStubAssembler) {
Return(BooleanConstant(false));
}
// ES6 section 20.1.2.12 Number.parseFloat ( string )
// ES6 #sec-number.parsefloat
TF_BUILTIN(NumberParseFloat, CodeStubAssembler) {
Node* context = Parameter(4);
Node* context = Parameter(Descriptor::kContext);
// We might need to loop once for ToString conversion.
Variable var_input(this, MachineRepresentation::kTagged);
Variable var_input(this, MachineRepresentation::kTagged,
Parameter(Descriptor::kString));
Label loop(this, &var_input);
var_input.Bind(Parameter(1));
Goto(&loop);
Bind(&loop);
{
......@@ -255,11 +255,11 @@ TF_BUILTIN(NumberParseFloat, CodeStubAssembler) {
}
}
// ES6 section 20.1.2.13 Number.parseInt ( string, radix )
// ES6 #sec-number.parseint
TF_BUILTIN(NumberParseInt, CodeStubAssembler) {
Node* input = Parameter(1);
Node* radix = Parameter(2);
Node* context = Parameter(5);
Node* context = Parameter(Descriptor::kContext);
Node* input = Parameter(Descriptor::kString);
Node* radix = Parameter(Descriptor::kRadix);
// Check if {radix} is treated as 10 (i.e. undefined, 0 or 10).
Label if_radix10(this), if_generic(this, Label::kDeferred);
......@@ -332,10 +332,10 @@ TF_BUILTIN(NumberParseInt, CodeStubAssembler) {
}
}
// ES6 section 20.1.3.7 Number.prototype.valueOf ( )
// ES6 #sec-number.prototype.valueof
TF_BUILTIN(NumberPrototypeValueOf, CodeStubAssembler) {
Node* receiver = Parameter(0);
Node* context = Parameter(3);
Node* context = Parameter(Descriptor::kContext);
Node* receiver = Parameter(Descriptor::kReceiver);
Node* result = ToThisValue(context, receiver, PrimitiveType::kNumber,
"Number.prototype.valueOf");
......@@ -343,9 +343,9 @@ TF_BUILTIN(NumberPrototypeValueOf, CodeStubAssembler) {
}
TF_BUILTIN(Add, CodeStubAssembler) {
Node* left = Parameter(0);
Node* right = Parameter(1);
Node* context = Parameter(2);
Node* context = Parameter(Descriptor::kContext);
Node* left = Parameter(Descriptor::kLeft);
Node* right = Parameter(Descriptor::kRight);
// Shared entry for floating point addition.
Label do_fadd(this);
......@@ -686,9 +686,9 @@ TF_BUILTIN(Add, CodeStubAssembler) {
}
TF_BUILTIN(Subtract, CodeStubAssembler) {
Node* left = Parameter(0);
Node* right = Parameter(1);
Node* context = Parameter(2);
Node* context = Parameter(Descriptor::kContext);
Node* left = Parameter(Descriptor::kLeft);
Node* right = Parameter(Descriptor::kRight);
// Shared entry for floating point subtraction.
Label do_fsub(this), end(this);
......@@ -845,9 +845,9 @@ TF_BUILTIN(Subtract, CodeStubAssembler) {
}
TF_BUILTIN(Multiply, CodeStubAssembler) {
Node* left = Parameter(0);
Node* right = Parameter(1);
Node* context = Parameter(2);
Node* context = Parameter(Descriptor::kContext);
Node* left = Parameter(Descriptor::kLeft);
Node* right = Parameter(Descriptor::kRight);
// Shared entry point for floating point multiplication.
Label do_fmul(this), return_result(this);
......@@ -982,9 +982,9 @@ TF_BUILTIN(Multiply, CodeStubAssembler) {
}
TF_BUILTIN(Divide, CodeStubAssembler) {
Node* left = Parameter(0);
Node* right = Parameter(1);
Node* context = Parameter(2);
Node* context = Parameter(Descriptor::kContext);
Node* left = Parameter(Descriptor::kLeft);
Node* right = Parameter(Descriptor::kRight);
// Shared entry point for floating point division.
Label do_fdiv(this), end(this);
......@@ -1177,9 +1177,9 @@ TF_BUILTIN(Divide, CodeStubAssembler) {
}
TF_BUILTIN(Modulus, CodeStubAssembler) {
Node* left = Parameter(0);
Node* right = Parameter(1);
Node* context = Parameter(2);
Node* context = Parameter(Descriptor::kContext);
Node* left = Parameter(Descriptor::kLeft);
Node* right = Parameter(Descriptor::kRight);
Variable var_result(this, MachineRepresentation::kTagged);
Label return_result(this, &var_result);
......
......@@ -477,6 +477,8 @@ TF_BUILTIN(StringCharCodeAt, CodeStubAssembler) {
// ES6 section 21.1.2.1 String.fromCharCode ( ...codeUnits )
TF_BUILTIN(StringFromCharCode, CodeStubAssembler) {
// TODO(ishell): use constants from Descriptor once the JSFunction linkage
// arguments are reordered.
Node* argc = Parameter(BuiltinDescriptor::kArgumentsCount);
Node* context = Parameter(BuiltinDescriptor::kContext);
......@@ -807,6 +809,8 @@ TF_BUILTIN(StringPrototypeIndexOf, StringBuiltinsAssembler) {
no_argc_0(this), argc_1(this), no_argc_1(this), argc_2(this),
fast_path(this), return_minus_1(this);
// TODO(ishell): use constants from Descriptor once the JSFunction linkage
// arguments are reordered.
Node* argc = Parameter(BuiltinDescriptor::kArgumentsCount);
Node* context = Parameter(BuiltinDescriptor::kContext);
......
......@@ -5,6 +5,8 @@
#ifndef V8_BUILTINS_BUILTINS_UTILS_GEN_H_
#define V8_BUILTINS_BUILTINS_UTILS_GEN_H_
#include "src/builtins/builtins-descriptors.h"
namespace v8 {
namespace internal {
......@@ -27,6 +29,8 @@ class CodeAssemblerState;
#define TF_BUILTIN(Name, AssemblerBase) \
class Name##Assembler : public AssemblerBase { \
public: \
typedef Builtin_##Name##_InterfaceDescriptor Descriptor; \
\
explicit Name##Assembler(compiler::CodeAssemblerState* state) \
: AssemblerBase(state) {} \
void Generate##Name##Impl(); \
......
......@@ -137,7 +137,7 @@ void Builtins::SetUp(Isolate* isolate, bool create_heap_objects) {
code = BuildAdaptor(isolate, FUNCTION_ADDR(Builtin_##Name), EXIT, \
kBuiltinFlags, #Name); \
builtins_[index++] = code;
#define BUILD_TFJ(Name, Argc) \
#define BUILD_TFJ(Name, Argc, ...) \
code = BuildWithCodeStubAssemblerJS(isolate, &Generate_##Name, Argc, \
kBuiltinFlags, #Name); \
builtins_[index++] = code;
......
......@@ -41,7 +41,7 @@ class Isolate;
// API: Builtin in C++ for API callbacks. Entered via EXIT frame.
// Args: name
// TFJ: Builtin in Turbofan, with JS linkage (callable as Javascript function).
// Args: name, arguments count
// Args: name, arguments count, explicit argument names...
// TFS: Builtin in Turbofan, with CodeStub linkage.
// Args: name, code kind, extra IC state, interface descriptor, return_size
// ASM: Builtin in platform-dependent assembly.
......@@ -265,24 +265,34 @@ class Isolate;
ASM(ArrayCode) \
ASM(InternalArrayCode) \
CPP(ArrayConcat) \
/* ES6 section 22.1.2.2 Array.isArray */ \
TFJ(ArrayIsArray, 1) \
/* ES6 #sec-array.isarray */ \
TFJ(ArrayIsArray, 1, kArg) \
/* ES7 #sec-array.prototype.includes */ \
TFJ(ArrayIncludes, 2) \
TFJ(ArrayIndexOf, 2) \
TFJ(ArrayIncludes, 2, kSearchElement, kFromIndex) \
/* ES6 #sec-array.prototype.indexof */ \
TFJ(ArrayIndexOf, 2, kSearchElement, kFromIndex) \
/* ES6 #sec-array.prototype.pop */ \
CPP(ArrayPop) \
/* ES6 #sec-array.prototype.push */ \
CPP(ArrayPush) \
TFJ(FastArrayPush, -1) \
TFJ(FastArrayPush, SharedFunctionInfo::kDontAdaptArgumentsSentinel) \
/* ES6 #sec-array.prototype.shift */ \
CPP(ArrayShift) \
/* ES6 #sec-array.prototype.slice */ \
CPP(ArraySlice) \
/* ES6 #sec-array.prototype.splice */ \
CPP(ArraySplice) \
/* ES6 #sec-array.prototype.unshift */ \
CPP(ArrayUnshift) \
/* ES6 #sec-array.prototype.foreach */ \
TFJ(ArrayForEachLoopContinuation, 6) \
TFJ(ArrayForEach, 2, kCallbackFn, kThisArg) \
/* ES6 #sec-array.prototype.every */ \
TFJ(ArrayEveryLoopContinuation, 6) \
TFJ(ArrayEvery, 2, kCallbackFn, kThisArg) \
/* ES6 #sec-array.prototype.some */ \
TFJ(ArraySomeLoopContinuation, 6) \
TFJ(ArrayForEach, 2) \
TFJ(ArrayEvery, 2) \
TFJ(ArraySome, 2) \
TFJ(ArraySome, 2, kCallbackFn, kThisArg) \
/* ES6 #sec-array.prototype.entries */ \
TFJ(ArrayPrototypeEntries, 0) \
/* ES6 #sec-array.prototype.keys */ \
......@@ -300,19 +310,19 @@ class Isolate;
CPP(ArrayBufferPrototypeSlice) \
\
/* AsyncFunction */ \
TFJ(AsyncFunctionAwaitCaught, 3) \
TFJ(AsyncFunctionAwaitUncaught, 3) \
TFJ(AsyncFunctionAwaitRejectClosure, 1) \
TFJ(AsyncFunctionAwaitResolveClosure, 1) \
TFJ(AsyncFunctionAwaitCaught, 3, kGenerator, kAwaited, kOuterPromise) \
TFJ(AsyncFunctionAwaitUncaught, 3, kGenerator, kAwaited, kOuterPromise) \
TFJ(AsyncFunctionAwaitRejectClosure, 1, kSentError) \
TFJ(AsyncFunctionAwaitResolveClosure, 1, kSentValue) \
TFJ(AsyncFunctionPromiseCreate, 0) \
TFJ(AsyncFunctionPromiseRelease, 1) \
TFJ(AsyncFunctionPromiseRelease, 1, kPromise) \
\
/* Boolean */ \
CPP(BooleanConstructor) \
CPP(BooleanConstructor_ConstructStub) \
/* ES6 section 19.3.3.2 Boolean.prototype.toString ( ) */ \
/* ES6 #sec-boolean.prototype.tostring */ \
TFJ(BooleanPrototypeToString, 0) \
/* ES6 section 19.3.3.3 Boolean.prototype.valueOf ( ) */ \
/* ES6 #sec-boolean.prototype.valueof */ \
TFJ(BooleanPrototypeValueOf, 0) \
\
/* CallSite */ \
......@@ -359,46 +369,46 @@ class Isolate;
/* Date */ \
CPP(DateConstructor) \
CPP(DateConstructor_ConstructStub) \
/* ES6 section 20.3.4.2 Date.prototype.getDate ( ) */ \
/* ES6 #sec-date.prototype.getdate */ \
TFJ(DatePrototypeGetDate, 0) \
/* ES6 section 20.3.4.3 Date.prototype.getDay ( ) */ \
/* ES6 #sec-date.prototype.getday */ \
TFJ(DatePrototypeGetDay, 0) \
/* ES6 section 20.3.4.4 Date.prototype.getFullYear ( ) */ \
/* ES6 #sec-date.prototype.getfullyear */ \
TFJ(DatePrototypeGetFullYear, 0) \
/* ES6 section 20.3.4.5 Date.prototype.getHours ( ) */ \
/* ES6 #sec-date.prototype.gethours */ \
TFJ(DatePrototypeGetHours, 0) \
/* ES6 section 20.3.4.6 Date.prototype.getMilliseconds ( ) */ \
/* ES6 #sec-date.prototype.getmilliseconds */ \
TFJ(DatePrototypeGetMilliseconds, 0) \
/* ES6 section 20.3.4.7 Date.prototype.getMinutes ( ) */ \
/* ES6 #sec-date.prototype.getminutes */ \
TFJ(DatePrototypeGetMinutes, 0) \
/* ES6 section 20.3.4.8 Date.prototype.getMonth */ \
/* ES6 #sec-date.prototype.getmonth */ \
TFJ(DatePrototypeGetMonth, 0) \
/* ES6 section 20.3.4.9 Date.prototype.getSeconds ( ) */ \
/* ES6 #sec-date.prototype.getseconds */ \
TFJ(DatePrototypeGetSeconds, 0) \
/* ES6 section 20.3.4.10 Date.prototype.getTime ( ) */ \
/* ES6 #sec-date.prototype.gettime */ \
TFJ(DatePrototypeGetTime, 0) \
/* ES6 section 20.3.4.11 Date.prototype.getTimezoneOffset ( ) */ \
/* ES6 #sec-date.prototype.gettimezoneoffset */ \
TFJ(DatePrototypeGetTimezoneOffset, 0) \
/* ES6 section 20.3.4.12 Date.prototype.getUTCDate ( ) */ \
/* ES6 #sec-date.prototype.getutcdate */ \
TFJ(DatePrototypeGetUTCDate, 0) \
/* ES6 section 20.3.4.13 Date.prototype.getUTCDay ( ) */ \
/* ES6 #sec-date.prototype.getutcday */ \
TFJ(DatePrototypeGetUTCDay, 0) \
/* ES6 section 20.3.4.14 Date.prototype.getUTCFullYear ( ) */ \
/* ES6 #sec-date.prototype.getutcfullyear */ \
TFJ(DatePrototypeGetUTCFullYear, 0) \
/* ES6 section 20.3.4.15 Date.prototype.getUTCHours ( ) */ \
/* ES6 #sec-date.prototype.getutchours */ \
TFJ(DatePrototypeGetUTCHours, 0) \
/* ES6 section 20.3.4.16 Date.prototype.getUTCMilliseconds ( ) */ \
/* ES6 #sec-date.prototype.getutcmilliseconds */ \
TFJ(DatePrototypeGetUTCMilliseconds, 0) \
/* ES6 section 20.3.4.17 Date.prototype.getUTCMinutes ( ) */ \
/* ES6 #sec-date.prototype.getutcminutes */ \
TFJ(DatePrototypeGetUTCMinutes, 0) \
/* ES6 section 20.3.4.18 Date.prototype.getUTCMonth ( ) */ \
/* ES6 #sec-date.prototype.getutcmonth */ \
TFJ(DatePrototypeGetUTCMonth, 0) \
/* ES6 section 20.3.4.19 Date.prototype.getUTCSeconds ( ) */ \
/* ES6 #sec-date.prototype.getutcseconds */ \
TFJ(DatePrototypeGetUTCSeconds, 0) \
/* ES6 section 20.3.4.44 Date.prototype.valueOf ( ) */ \
/* ES6 #sec-date.prototype.valueof */ \
TFJ(DatePrototypeValueOf, 0) \
/* ES6 section 20.3.4.45 Date.prototype [ @@toPrimitive ] ( hint ) */ \
TFJ(DatePrototypeToPrimitive, 1) \
/* ES6 #sec-date.prototype-@@toprimitive */ \
TFJ(DatePrototypeToPrimitive, 1, kHint) \
CPP(DatePrototypeGetYear) \
CPP(DatePrototypeSetYear) \
CPP(DateNow) \
......@@ -440,11 +450,13 @@ class Isolate;
CPP(FunctionConstructor) \
ASM(FunctionPrototypeApply) \
CPP(FunctionPrototypeBind) \
/* ES6 #sec-function.prototype.bind */ \
TFJ(FastFunctionPrototypeBind, \
SharedFunctionInfo::kDontAdaptArgumentsSentinel) \
ASM(FunctionPrototypeCall) \
/* ES6 section 19.2.3.6 Function.prototype [ @@hasInstance ] ( V ) */ \
TFJ(FunctionPrototypeHasInstance, 1) \
/* ES6 #sec-function.prototype-@@hasinstance */ \
TFJ(FunctionPrototypeHasInstance, 1, kV) \
/* ES6 #sec-function.prototype.tostring */ \
CPP(FunctionPrototypeToString) \
\
/* Belongs to Objects but is a dependency of GeneratorPrototypeResume */ \
......@@ -453,12 +465,12 @@ class Isolate;
\
/* Generator and Async */ \
CPP(GeneratorFunctionConstructor) \
/* ES6 section 25.3.1.2 Generator.prototype.next ( value ) */ \
TFJ(GeneratorPrototypeNext, 1) \
/* ES6 section 25.3.1.3 Generator.prototype.return ( value ) */ \
TFJ(GeneratorPrototypeReturn, 1) \
/* ES6 section 25.3.1.4 Generator.prototype.throw ( exception ) */ \
TFJ(GeneratorPrototypeThrow, 1) \
/* ES6 #sec-generator.prototype.next */ \
TFJ(GeneratorPrototypeNext, 1, kValue) \
/* ES6 #sec-generator.prototype.return */ \
TFJ(GeneratorPrototypeReturn, 1, kValue) \
/* ES6 #sec-generator.prototype.throw */ \
TFJ(GeneratorPrototypeThrow, 1, kException) \
CPP(AsyncFunctionConstructor) \
\
/* Global object */ \
......@@ -469,10 +481,10 @@ class Isolate;
CPP(GlobalEscape) \
CPP(GlobalUnescape) \
CPP(GlobalEval) \
/* ES6 section 18.2.2 isFinite ( number ) */ \
TFJ(GlobalIsFinite, 1) \
/* ES6 section 18.2.3 isNaN ( number ) */ \
TFJ(GlobalIsNaN, 1) \
/* ES6 #sec-isfinite-number */ \
TFJ(GlobalIsFinite, 1, kNumber) \
/* ES6 #sec-isnan-number */ \
TFJ(GlobalIsNaN, 1, kNumber) \
\
/* JSON */ \
CPP(JsonParse) \
......@@ -500,100 +512,100 @@ class Isolate;
LoadGlobal, 1) \
\
/* Math */ \
/* ES6 section 20.2.2.1 Math.abs ( x ) */ \
TFJ(MathAbs, 1) \
/* ES6 section 20.2.2.2 Math.acos ( x ) */ \
TFJ(MathAcos, 1) \
/* ES6 section 20.2.2.3 Math.acosh ( x ) */ \
TFJ(MathAcosh, 1) \
/* ES6 section 20.2.2.4 Math.asin ( x ) */ \
TFJ(MathAsin, 1) \
/* ES6 section 20.2.2.5 Math.asinh ( x ) */ \
TFJ(MathAsinh, 1) \
/* ES6 section 20.2.2.6 Math.atan ( x ) */ \
TFJ(MathAtan, 1) \
/* ES6 section 20.2.2.7 Math.atanh ( x ) */ \
TFJ(MathAtanh, 1) \
/* ES6 section 20.2.2.8 Math.atan2 ( y, x ) */ \
TFJ(MathAtan2, 2) \
/* ES6 section 20.2.2.9 Math.cbrt ( x ) */ \
TFJ(MathCbrt, 1) \
/* ES6 section 20.2.2.10 Math.ceil ( x ) */ \
TFJ(MathCeil, 1) \
/* ES6 section 20.2.2.11 Math.clz32 ( x ) */ \
TFJ(MathClz32, 1) \
/* ES6 section 20.2.2.12 Math.cos ( x ) */ \
TFJ(MathCos, 1) \
/* ES6 section 20.2.2.13 Math.cosh ( x ) */ \
TFJ(MathCosh, 1) \
/* ES6 section 20.2.2.14 Math.exp ( x ) */ \
TFJ(MathExp, 1) \
/* ES6 section 20.2.2.15 Math.expm1 ( x ) */ \
TFJ(MathExpm1, 1) \
/* ES6 section 20.2.2.16 Math.floor ( x ) */ \
TFJ(MathFloor, 1) \
/* ES6 section 20.2.2.17 Math.fround ( x ) */ \
TFJ(MathFround, 1) \
/* ES6 section 20.2.2.18 Math.hypot ( value1, value2, ...values ) */ \
/* ES6 #sec-math.abs */ \
TFJ(MathAbs, 1, kX) \
/* ES6 #sec-math.acos */ \
TFJ(MathAcos, 1, kX) \
/* ES6 #sec-math.acosh */ \
TFJ(MathAcosh, 1, kX) \
/* ES6 #sec-math.asin */ \
TFJ(MathAsin, 1, kX) \
/* ES6 #sec-math.asinh */ \
TFJ(MathAsinh, 1, kX) \
/* ES6 #sec-math.atan */ \
TFJ(MathAtan, 1, kX) \
/* ES6 #sec-math.atanh */ \
TFJ(MathAtanh, 1, kX) \
/* ES6 #sec-math.atan2 */ \
TFJ(MathAtan2, 2, kY, kX) \
/* ES6 #sec-math.cbrt */ \
TFJ(MathCbrt, 1, kX) \
/* ES6 #sec-math.ceil */ \
TFJ(MathCeil, 1, kX) \
/* ES6 #sec-math.clz32 */ \
TFJ(MathClz32, 1, kX) \
/* ES6 #sec-math.cos */ \
TFJ(MathCos, 1, kX) \
/* ES6 #sec-math.cosh */ \
TFJ(MathCosh, 1, kX) \
/* ES6 #sec-math.exp */ \
TFJ(MathExp, 1, kX) \
/* ES6 #sec-math.expm1 */ \
TFJ(MathExpm1, 1, kX) \
/* ES6 #sec-math.floor */ \
TFJ(MathFloor, 1, kX) \
/* ES6 #sec-math.fround */ \
TFJ(MathFround, 1, kX) \
/* ES6 #sec-math.hypot */ \
CPP(MathHypot) \
/* ES6 section 20.2.2.19 Math.imul ( x, y ) */ \
TFJ(MathImul, 2) \
/* ES6 section 20.2.2.20 Math.log ( x ) */ \
TFJ(MathLog, 1) \
/* ES6 section 20.2.2.21 Math.log1p ( x ) */ \
TFJ(MathLog1p, 1) \
/* ES6 section 20.2.2.22 Math.log10 ( x ) */ \
TFJ(MathLog10, 1) \
/* ES6 section 20.2.2.23 Math.log2 ( x ) */ \
TFJ(MathLog2, 1) \
/* ES6 section 20.2.2.24 Math.max ( value1, value2 , ...values ) */ \
/* ES6 #sec-math.imul */ \
TFJ(MathImul, 2, kX, kY) \
/* ES6 #sec-math.log */ \
TFJ(MathLog, 1, kX) \
/* ES6 #sec-math.log1p */ \
TFJ(MathLog1p, 1, kX) \
/* ES6 #sec-math.log10 */ \
TFJ(MathLog10, 1, kX) \
/* ES6 #sec-math.log2 */ \
TFJ(MathLog2, 1, kX) \
/* ES6 #sec-math.max */ \
TFJ(MathMax, SharedFunctionInfo::kDontAdaptArgumentsSentinel) \
/* ES6 section 20.2.2.25 Math.min ( value1, value2 , ...values ) */ \
/* ES6 #sec-math.min */ \
TFJ(MathMin, SharedFunctionInfo::kDontAdaptArgumentsSentinel) \
/* ES6 section 20.2.2.26 Math.pow ( x, y ) */ \
TFJ(MathPow, 2) \
/* ES6 section 20.2.2.27 Math.random */ \
/* ES6 #sec-math.pow */ \
TFJ(MathPow, 2, kBase, kExponent) \
/* ES6 #sec-math.random */ \
TFJ(MathRandom, 0) \
/* ES6 section 20.2.2.28 Math.round ( x ) */ \
TFJ(MathRound, 1) \
/* ES6 section 20.2.2.29 Math.sign ( x ) */ \
TFJ(MathSign, 1) \
/* ES6 section 20.2.2.30 Math.sin ( x ) */ \
TFJ(MathSin, 1) \
/* ES6 section 20.2.2.31 Math.sinh ( x ) */ \
TFJ(MathSinh, 1) \
/* ES6 section 20.2.2.32 Math.sqrt ( x ) */ \
TFJ(MathTan, 1) \
/* ES6 section 20.2.2.33 Math.tan ( x ) */ \
TFJ(MathTanh, 1) \
/* ES6 section 20.2.2.34 Math.tanh ( x ) */ \
TFJ(MathSqrt, 1) \
/* ES6 section 20.2.2.35 Math.trunc ( x ) */ \
TFJ(MathTrunc, 1) \
/* ES6 #sec-math.round */ \
TFJ(MathRound, 1, kX) \
/* ES6 #sec-math.sign */ \
TFJ(MathSign, 1, kX) \
/* ES6 #sec-math.sin */ \
TFJ(MathSin, 1, kX) \
/* ES6 #sec-math.sinh */ \
TFJ(MathSinh, 1, kX) \
/* ES6 #sec-math.sqrt */ \
TFJ(MathTan, 1, kX) \
/* ES6 #sec-math.tan */ \
TFJ(MathTanh, 1, kX) \
/* ES6 #sec-math.tanh */ \
TFJ(MathSqrt, 1, kX) \
/* ES6 #sec-math.trunc */ \
TFJ(MathTrunc, 1, kX) \
\
/* Number */ \
/* ES6 section 20.1.1.1 Number ( [ value ] ) for the [[Call]] case */ \
ASM(NumberConstructor) \
/* ES6 section 20.1.1.1 Number ( [ value ] ) for the [[Construct]] case */ \
ASM(NumberConstructor_ConstructStub) \
/* ES6 section 20.1.2.2 Number.isFinite ( number ) */ \
TFJ(NumberIsFinite, 1) \
/* ES6 section 20.1.2.3 Number.isInteger ( number ) */ \
TFJ(NumberIsInteger, 1) \
/* ES6 section 20.1.2.4 Number.isNaN ( number ) */ \
TFJ(NumberIsNaN, 1) \
/* ES6 section 20.1.2.5 Number.isSafeInteger ( number ) */ \
TFJ(NumberIsSafeInteger, 1) \
/* ES6 section 20.1.2.12 Number.parseFloat ( string ) */ \
TFJ(NumberParseFloat, 1) \
/* ES6 section 20.1.2.13 Number.parseInt ( string, radix ) */ \
TFJ(NumberParseInt, 2) \
/* ES6 #sec-number.isfinite */ \
TFJ(NumberIsFinite, 1, kNumber) \
/* ES6 #sec-number.isinteger */ \
TFJ(NumberIsInteger, 1, kNumber) \
/* ES6 #sec-number.isnan */ \
TFJ(NumberIsNaN, 1, kNumber) \
/* ES6 #sec-number.issafeinteger */ \
TFJ(NumberIsSafeInteger, 1, kNumber) \
/* ES6 #sec-number.parsefloat */ \
TFJ(NumberParseFloat, 1, kString) \
/* ES6 #sec-number.parseint */ \
TFJ(NumberParseInt, 2, kString, kRadix) \
CPP(NumberPrototypeToExponential) \
CPP(NumberPrototypeToFixed) \
CPP(NumberPrototypeToLocaleString) \
CPP(NumberPrototypeToPrecision) \
CPP(NumberPrototypeToString) \
/* ES6 section 20.1.3.7 Number.prototype.valueOf ( ) */ \
/* ES6 #sec-number.prototype.valueof */ \
TFJ(NumberPrototypeValueOf, 0) \
TFS(Add, BUILTIN, kNoExtraICState, BinaryOp, 1) \
TFS(Subtract, BUILTIN, kNoExtraICState, BinaryOp, 1) \
......
......@@ -5,6 +5,7 @@
#include "src/code-factory.h"
#include "src/bootstrapper.h"
#include "src/builtins/builtins-descriptors.h"
#include "src/ic/ic.h"
#include "src/objects-inl.h"
......@@ -223,16 +224,10 @@ Callable CodeFactory::StringFromCharCode(Isolate* isolate) {
return Callable(code, BuiltinDescriptor(isolate));
}
#define DECLARE_TFS(Name, Kind, Extra, InterfaceDescriptor, result_size) \
typedef InterfaceDescriptor##Descriptor Name##Descriptor;
BUILTIN_LIST(IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN, DECLARE_TFS,
IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN)
#undef DECLARE_TFS
#define TFS_BUILTIN(Name) \
Callable CodeFactory::Name(Isolate* isolate) { \
Handle<Code> code(isolate->builtins()->Name()); \
return Callable(code, Name##Descriptor(isolate)); \
#define TFS_BUILTIN(Name) \
Callable CodeFactory::Name(Isolate* isolate) { \
Handle<Code> code(isolate->builtins()->Name()); \
return Callable(code, Builtin_##Name##_InterfaceDescriptor(isolate)); \
}
TFS_BUILTIN(ToString)
......@@ -274,6 +269,9 @@ TFS_BUILTIN(NewUnmappedArgumentsElements)
TFS_BUILTIN(FastCloneRegExp)
TFS_BUILTIN(FastNewClosure)
TFS_BUILTIN(FastNewObject)
TFS_BUILTIN(FastNewRestParameter)
TFS_BUILTIN(FastNewSloppyArguments)
TFS_BUILTIN(FastNewStrictArguments)
TFS_BUILTIN(ForInFilter)
TFS_BUILTIN(GetSuperConstructor)
TFS_BUILTIN(LoadIC_Uninitialized)
......@@ -369,24 +367,6 @@ Callable CodeFactory::FastNewFunctionContext(Isolate* isolate,
FastNewFunctionContextDescriptor(isolate));
}
// static
Callable CodeFactory::FastNewRestParameter(Isolate* isolate) {
return Callable(isolate->builtins()->FastNewRestParameter(),
FastNewRestParameterDescriptor(isolate));
}
// static
Callable CodeFactory::FastNewSloppyArguments(Isolate* isolate) {
return Callable(isolate->builtins()->FastNewSloppyArguments(),
FastNewRestParameterDescriptor(isolate));
}
// static
Callable CodeFactory::FastNewStrictArguments(Isolate* isolate) {
return Callable(isolate->builtins()->FastNewStrictArguments(),
FastNewRestParameterDescriptor(isolate));
}
// static
Callable CodeFactory::ForInPrepare(Isolate* isolate) {
return Callable(isolate->builtins()->ForInPrepare(),
......
......@@ -494,6 +494,7 @@
'builtins/builtins-date.cc',
'builtins/builtins-date-gen.cc',
'builtins/builtins-debug.cc',
'builtins/builtins-descriptors.h',
'builtins/builtins-error.cc',
'builtins/builtins-forin-gen.cc',
'builtins/builtins-forin.h',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment