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

Third bulk of changes.

BUG=v8:6116

Change-Id: I26f5c03a44e55a998e71160a42f6e2c1509f41c7
Reviewed-on: https://chromium-review.googlesource.com/458197
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#44011}
This commit is contained in:
Igor Sheludko 2017-03-22 09:55:52 +01:00 committed by Commit Bot
parent 4e92e12485
commit dfcc4aa34a
10 changed files with 104 additions and 75 deletions

View File

@ -677,14 +677,15 @@ Node* ConstructorBuiltinsAssembler::EmitFastCloneShallowObject(
return copy;
}
template <typename Descriptor>
void ConstructorBuiltinsAssembler::CreateFastCloneShallowObjectBuiltin(
int properties_count) {
DCHECK_GE(properties_count, 0);
DCHECK_LE(properties_count,
ConstructorBuiltins::kMaximumClonedShallowObjectProperties);
Label call_runtime(this);
Node* closure = Parameter(0);
Node* literals_index = Parameter(1);
Node* closure = Parameter(Descriptor::kClosure);
Node* literals_index = Parameter(Descriptor::kLiteralIndex);
Node* properties_count_node =
IntPtrConstant(ConstructorBuiltins::FastCloneShallowObjectPropertiesCount(
@ -694,16 +695,16 @@ void ConstructorBuiltinsAssembler::CreateFastCloneShallowObjectBuiltin(
Return(copy);
Bind(&call_runtime);
Node* constant_properties = Parameter(2);
Node* flags = Parameter(3);
Node* context = Parameter(4);
Node* constant_properties = Parameter(Descriptor::kConstantProperties);
Node* flags = Parameter(Descriptor::kFlags);
Node* context = Parameter(Descriptor::kContext);
TailCallRuntime(Runtime::kCreateObjectLiteral, context, closure,
literals_index, constant_properties, flags);
}
#define SHALLOW_OBJECT_BUILTIN(props) \
TF_BUILTIN(FastCloneShallowObject##props, ConstructorBuiltinsAssembler) { \
CreateFastCloneShallowObjectBuiltin(props); \
CreateFastCloneShallowObjectBuiltin<Descriptor>(props); \
}
SHALLOW_OBJECT_BUILTIN(0);

View File

@ -32,6 +32,8 @@ class ConstructorBuiltinsAssembler : public CodeStubAssembler {
Node* EmitFastCloneShallowObject(Label* call_runtime, Node* closure,
Node* literals_index,
Node* properties_count);
template <typename Descriptor>
void CreateFastCloneShallowObjectBuiltin(int properties_count);
Node* EmitFastNewObject(Node* context, Node* target, Node* new_target);

View File

@ -239,10 +239,11 @@ TF_BUILTIN(ToBoolean, CodeStubAssembler) {
}
TF_BUILTIN(ToLength, CodeStubAssembler) {
Node* context = Parameter(1);
Node* context = Parameter(Descriptor::kContext);
// We might need to loop once for ToNumber conversion.
Variable var_len(this, MachineRepresentation::kTagged, Parameter(0));
Variable var_len(this, MachineRepresentation::kTagged,
Parameter(Descriptor::kArgument));
Label loop(this, &var_len);
Goto(&loop);
Bind(&loop);

View File

@ -253,7 +253,7 @@ TF_BUILTIN(MathCbrt, MathBuiltinsAssembler) {
// ES6 #sec-math.clz32
TF_BUILTIN(MathClz32, CodeStubAssembler) {
Node* context = Parameter(4);
Node* context = Parameter(Descriptor::kContext);
// Shared entry point for the clz32 operation.
Variable var_clz32_x(this, MachineRepresentation::kWord32);
@ -262,7 +262,7 @@ TF_BUILTIN(MathClz32, CodeStubAssembler) {
// 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);
{

View File

@ -18,11 +18,12 @@ class NumberBuiltinsAssembler : public CodeStubAssembler {
: CodeStubAssembler(state) {}
protected:
template <Signedness signed_result = kSigned>
void BitwiseOp(std::function<Node*(Node* lhs, Node* rhs)> body) {
Node* left = Parameter(0);
Node* right = Parameter(1);
Node* context = Parameter(2);
template <typename Descriptor>
void BitwiseOp(std::function<Node*(Node* lhs, Node* rhs)> body,
Signedness signed_result = kSigned) {
Node* left = Parameter(Descriptor::kLeft);
Node* right = Parameter(Descriptor::kRight);
Node* context = Parameter(Descriptor::kContext);
Node* lhs_value = TruncateTaggedToWord32(context, left);
Node* rhs_value = TruncateTaggedToWord32(context, right);
@ -32,18 +33,22 @@ class NumberBuiltinsAssembler : public CodeStubAssembler {
Return(result);
}
template <Signedness signed_result = kSigned>
void BitwiseShiftOp(std::function<Node*(Node* lhs, Node* shift_count)> body) {
BitwiseOp<signed_result>([=](Node* lhs, Node* rhs) {
Node* shift_count = Word32And(rhs, Int32Constant(0x1f));
return body(lhs, shift_count);
});
template <typename Descriptor>
void BitwiseShiftOp(std::function<Node*(Node* lhs, Node* shift_count)> body,
Signedness signed_result = kSigned) {
BitwiseOp<Descriptor>(
[=](Node* lhs, Node* rhs) {
Node* shift_count = Word32And(rhs, Int32Constant(0x1f));
return body(lhs, shift_count);
},
signed_result);
}
template <typename Descriptor>
void RelationalComparisonBuiltin(RelationalComparisonMode mode) {
Node* lhs = Parameter(0);
Node* rhs = Parameter(1);
Node* context = Parameter(2);
Node* lhs = Parameter(Descriptor::kLeft);
Node* rhs = Parameter(Descriptor::kRight);
Node* context = Parameter(Descriptor::kContext);
Return(RelationalComparison(mode, lhs, rhs, context));
}
@ -1324,62 +1329,65 @@ TF_BUILTIN(Modulus, CodeStubAssembler) {
}
TF_BUILTIN(ShiftLeft, NumberBuiltinsAssembler) {
BitwiseShiftOp([this](Node* lhs, Node* shift_count) {
BitwiseShiftOp<Descriptor>([=](Node* lhs, Node* shift_count) {
return Word32Shl(lhs, shift_count);
});
}
TF_BUILTIN(ShiftRight, NumberBuiltinsAssembler) {
BitwiseShiftOp([this](Node* lhs, Node* shift_count) {
BitwiseShiftOp<Descriptor>([=](Node* lhs, Node* shift_count) {
return Word32Sar(lhs, shift_count);
});
}
TF_BUILTIN(ShiftRightLogical, NumberBuiltinsAssembler) {
BitwiseShiftOp<kUnsigned>([this](Node* lhs, Node* shift_count) {
return Word32Shr(lhs, shift_count);
});
BitwiseShiftOp<Descriptor>(
[=](Node* lhs, Node* shift_count) { return Word32Shr(lhs, shift_count); },
kUnsigned);
}
TF_BUILTIN(BitwiseAnd, NumberBuiltinsAssembler) {
BitwiseOp([this](Node* lhs, Node* rhs) { return Word32And(lhs, rhs); });
BitwiseOp<Descriptor>(
[=](Node* lhs, Node* rhs) { return Word32And(lhs, rhs); });
}
TF_BUILTIN(BitwiseOr, NumberBuiltinsAssembler) {
BitwiseOp([this](Node* lhs, Node* rhs) { return Word32Or(lhs, rhs); });
BitwiseOp<Descriptor>(
[=](Node* lhs, Node* rhs) { return Word32Or(lhs, rhs); });
}
TF_BUILTIN(BitwiseXor, NumberBuiltinsAssembler) {
BitwiseOp([this](Node* lhs, Node* rhs) { return Word32Xor(lhs, rhs); });
BitwiseOp<Descriptor>(
[=](Node* lhs, Node* rhs) { return Word32Xor(lhs, rhs); });
}
TF_BUILTIN(LessThan, NumberBuiltinsAssembler) {
RelationalComparisonBuiltin(kLessThan);
RelationalComparisonBuiltin<Descriptor>(kLessThan);
}
TF_BUILTIN(LessThanOrEqual, NumberBuiltinsAssembler) {
RelationalComparisonBuiltin(kLessThanOrEqual);
RelationalComparisonBuiltin<Descriptor>(kLessThanOrEqual);
}
TF_BUILTIN(GreaterThan, NumberBuiltinsAssembler) {
RelationalComparisonBuiltin(kGreaterThan);
RelationalComparisonBuiltin<Descriptor>(kGreaterThan);
}
TF_BUILTIN(GreaterThanOrEqual, NumberBuiltinsAssembler) {
RelationalComparisonBuiltin(kGreaterThanOrEqual);
RelationalComparisonBuiltin<Descriptor>(kGreaterThanOrEqual);
}
TF_BUILTIN(Equal, CodeStubAssembler) {
Node* lhs = Parameter(0);
Node* rhs = Parameter(1);
Node* context = Parameter(2);
Node* lhs = Parameter(Descriptor::kLeft);
Node* rhs = Parameter(Descriptor::kRight);
Node* context = Parameter(Descriptor::kContext);
Return(Equal(lhs, rhs, context));
}
TF_BUILTIN(StrictEqual, CodeStubAssembler) {
Node* lhs = Parameter(0);
Node* rhs = Parameter(1);
Node* lhs = Parameter(Descriptor::kLeft);
Node* rhs = Parameter(Descriptor::kRight);
Return(StrictEqual(lhs, rhs));
}

View File

@ -50,9 +50,9 @@ void ObjectBuiltinsAssembler::ReturnToStringFormat(Node* context,
}
TF_BUILTIN(ObjectHasOwnProperty, ObjectBuiltinsAssembler) {
Node* object = Parameter(0);
Node* key = Parameter(1);
Node* context = Parameter(4);
Node* object = Parameter(Descriptor::kReceiver);
Node* key = Parameter(Descriptor::kKey);
Node* context = Parameter(Descriptor::kContext);
Label call_runtime(this), return_true(this), return_false(this);

View File

@ -98,8 +98,10 @@ class StringBuiltinsAssembler : public CodeStubAssembler {
arraysize(values));
}
void GenerateStringEqual();
void GenerateStringRelationalComparison(RelationalComparisonMode mode);
void GenerateStringEqual(Node* context, Node* left, Node* right);
void GenerateStringRelationalComparison(Node* context, Node* left,
Node* right,
RelationalComparisonMode mode);
Node* ToSmiBetweenZeroAnd(Node* context, Node* value, Node* limit);
@ -137,7 +139,8 @@ class StringBuiltinsAssembler : public CodeStubAssembler {
const NodeFunction1& generic_call);
};
void StringBuiltinsAssembler::GenerateStringEqual() {
void StringBuiltinsAssembler::GenerateStringEqual(Node* context, Node* left,
Node* right) {
// Here's pseudo-code for the algorithm below:
//
// if (lhs == rhs) return true;
@ -156,11 +159,8 @@ void StringBuiltinsAssembler::GenerateStringEqual() {
// }
// return %StringEqual(lhs, rhs);
Variable var_left(this, MachineRepresentation::kTagged);
Variable var_right(this, MachineRepresentation::kTagged);
var_left.Bind(Parameter(0));
var_right.Bind(Parameter(1));
Node* context = Parameter(2);
Variable var_left(this, MachineRepresentation::kTagged, left);
Variable var_right(this, MachineRepresentation::kTagged, right);
Variable* input_vars[2] = {&var_left, &var_right};
Label if_equal(this), if_notequal(this), restart(this, 2, input_vars);
@ -265,12 +265,9 @@ void StringBuiltinsAssembler::GenerateStringEqual() {
}
void StringBuiltinsAssembler::GenerateStringRelationalComparison(
RelationalComparisonMode mode) {
Variable var_left(this, MachineRepresentation::kTagged);
Variable var_right(this, MachineRepresentation::kTagged);
var_left.Bind(Parameter(0));
var_right.Bind(Parameter(1));
Node* context = Parameter(2);
Node* context, Node* left, Node* right, RelationalComparisonMode mode) {
Variable var_left(this, MachineRepresentation::kTagged, left);
Variable var_right(this, MachineRepresentation::kTagged, right);
Variable* input_vars[2] = {&var_left, &var_right};
Label if_less(this), if_equal(this), if_greater(this);
@ -427,29 +424,48 @@ void StringBuiltinsAssembler::GenerateStringRelationalComparison(
}
}
TF_BUILTIN(StringEqual, StringBuiltinsAssembler) { GenerateStringEqual(); }
TF_BUILTIN(StringEqual, StringBuiltinsAssembler) {
Node* context = Parameter(Descriptor::kContext);
Node* left = Parameter(Descriptor::kLeft);
Node* right = Parameter(Descriptor::kRight);
GenerateStringEqual(context, left, right);
}
TF_BUILTIN(StringLessThan, StringBuiltinsAssembler) {
GenerateStringRelationalComparison(RelationalComparisonMode::kLessThan);
Node* context = Parameter(Descriptor::kContext);
Node* left = Parameter(Descriptor::kLeft);
Node* right = Parameter(Descriptor::kRight);
GenerateStringRelationalComparison(context, left, right,
RelationalComparisonMode::kLessThan);
}
TF_BUILTIN(StringLessThanOrEqual, StringBuiltinsAssembler) {
Node* context = Parameter(Descriptor::kContext);
Node* left = Parameter(Descriptor::kLeft);
Node* right = Parameter(Descriptor::kRight);
GenerateStringRelationalComparison(
RelationalComparisonMode::kLessThanOrEqual);
context, left, right, RelationalComparisonMode::kLessThanOrEqual);
}
TF_BUILTIN(StringGreaterThan, StringBuiltinsAssembler) {
GenerateStringRelationalComparison(RelationalComparisonMode::kGreaterThan);
Node* context = Parameter(Descriptor::kContext);
Node* left = Parameter(Descriptor::kLeft);
Node* right = Parameter(Descriptor::kRight);
GenerateStringRelationalComparison(context, left, right,
RelationalComparisonMode::kGreaterThan);
}
TF_BUILTIN(StringGreaterThanOrEqual, StringBuiltinsAssembler) {
Node* context = Parameter(Descriptor::kContext);
Node* left = Parameter(Descriptor::kLeft);
Node* right = Parameter(Descriptor::kRight);
GenerateStringRelationalComparison(
RelationalComparisonMode::kGreaterThanOrEqual);
context, left, right, RelationalComparisonMode::kGreaterThanOrEqual);
}
TF_BUILTIN(StringCharAt, CodeStubAssembler) {
Node* receiver = Parameter(0);
Node* position = Parameter(1);
Node* receiver = Parameter(Descriptor::kReceiver);
Node* position = Parameter(Descriptor::kPosition);
// Load the character code at the {position} from the {receiver}.
Node* code = StringCharCodeAt(receiver, position, INTPTR_PARAMETERS);
@ -460,8 +476,8 @@ TF_BUILTIN(StringCharAt, CodeStubAssembler) {
}
TF_BUILTIN(StringCharCodeAt, CodeStubAssembler) {
Node* receiver = Parameter(0);
Node* position = Parameter(1);
Node* receiver = Parameter(Descriptor::kReceiver);
Node* position = Parameter(Descriptor::kPosition);
// Load the character code at the {position} from the {receiver}.
Node* code = StringCharCodeAt(receiver, position, INTPTR_PARAMETERS);
@ -814,9 +830,9 @@ void StringBuiltinsAssembler::StringIndexOf(
// #sec-string.prototype.indexof
// Unchecked helper for builtins lowering.
TF_BUILTIN(StringIndexOf, StringBuiltinsAssembler) {
Node* receiver = Parameter(0);
Node* search_string = Parameter(1);
Node* position = Parameter(2);
Node* receiver = Parameter(Descriptor::kReceiver);
Node* search_string = Parameter(Descriptor::kSearchString);
Node* position = Parameter(Descriptor::kPosition);
Node* instance_type = LoadInstanceType(receiver);
Node* search_string_instance_type = LoadInstanceType(search_string);

View File

@ -653,7 +653,7 @@ class Isolate;
CPP(ObjectGetPrototypeOf) \
CPP(ObjectSetPrototypeOf) \
/* ES6 #sec-object.prototype.hasownproperty */ \
TFJ(ObjectHasOwnProperty, 1) \
TFJ(ObjectHasOwnProperty, 1, kKey) \
CPP(ObjectIs) \
CPP(ObjectIsExtensible) \
CPP(ObjectIsFrozen) \

View File

@ -494,7 +494,7 @@ void AllocateHeapNumberStub::GenerateAssembly(
void StringLengthStub::GenerateAssembly(
compiler::CodeAssemblerState* state) const {
CodeStubAssembler assembler(state);
compiler::Node* value = assembler.Parameter(0);
compiler::Node* value = assembler.Parameter(Descriptor::kReceiver);
compiler::Node* string = assembler.LoadJSValueValue(value);
compiler::Node* result = assembler.LoadStringLength(string);
assembler.Return(result);
@ -1857,9 +1857,9 @@ void GetPropertyStub::GenerateAssembly(
Label call_runtime(&assembler, Label::kDeferred),
return_undefined(&assembler), end(&assembler);
Node* object = assembler.Parameter(0);
Node* key = assembler.Parameter(1);
Node* context = assembler.Parameter(2);
Node* object = assembler.Parameter(Descriptor::kObject);
Node* key = assembler.Parameter(Descriptor::kKey);
Node* context = assembler.Parameter(Descriptor::kContext);
Variable var_result(&assembler, MachineRepresentation::kTagged);
CodeStubAssembler::LookupInHolder lookup_property_in_holder =

View File

@ -571,6 +571,7 @@ class FastCloneShallowArrayDescriptor : public CallInterfaceDescriptor {
class FastCloneShallowObjectDescriptor : public CallInterfaceDescriptor {
public:
DEFINE_PARAMETERS(kClosure, kLiteralIndex, kConstantProperties, kFlags)
DECLARE_DESCRIPTOR(FastCloneShallowObjectDescriptor, CallInterfaceDescriptor)
};