Commit 87a65911 authored by jkummerow's avatar jkummerow Committed by Commit bot

Reland of [refactoring] Split CodeAssemblerState out of CodeAssembler

This is in preparation for introducing more specialized
CodeStubAssembler subclasses. The state object can be handed
around, while the Assembler instances are temporary-scoped.

BUG=v8:5628

Original review: https://codereview.chromium.org/2498073002/

Review-Url: https://codereview.chromium.org/2502293002
Cr-Commit-Position: refs/heads/master@{#41028}
parent c93bdaaf
This diff is collapsed.
...@@ -34,28 +34,32 @@ BUILTIN(BooleanConstructor_ConstructStub) { ...@@ -34,28 +34,32 @@ BUILTIN(BooleanConstructor_ConstructStub) {
} }
// ES6 section 19.3.3.2 Boolean.prototype.toString ( ) // ES6 section 19.3.3.2 Boolean.prototype.toString ( )
void Builtins::Generate_BooleanPrototypeToString(CodeStubAssembler* assembler) { void Builtins::Generate_BooleanPrototypeToString(
compiler::CodeAssemblerState* state) {
typedef compiler::Node Node; typedef compiler::Node Node;
CodeStubAssembler assembler(state);
Node* receiver = assembler->Parameter(0); Node* receiver = assembler.Parameter(0);
Node* context = assembler->Parameter(3); Node* context = assembler.Parameter(3);
Node* value = assembler->ToThisValue( Node* value = assembler.ToThisValue(
context, receiver, PrimitiveType::kBoolean, "Boolean.prototype.toString"); context, receiver, PrimitiveType::kBoolean, "Boolean.prototype.toString");
Node* result = assembler->LoadObjectField(value, Oddball::kToStringOffset); Node* result = assembler.LoadObjectField(value, Oddball::kToStringOffset);
assembler->Return(result); assembler.Return(result);
} }
// ES6 section 19.3.3.3 Boolean.prototype.valueOf ( ) // ES6 section 19.3.3.3 Boolean.prototype.valueOf ( )
void Builtins::Generate_BooleanPrototypeValueOf(CodeStubAssembler* assembler) { void Builtins::Generate_BooleanPrototypeValueOf(
compiler::CodeAssemblerState* state) {
typedef compiler::Node Node; typedef compiler::Node Node;
CodeStubAssembler assembler(state);
Node* receiver = assembler->Parameter(0); Node* receiver = assembler.Parameter(0);
Node* context = assembler->Parameter(3); Node* context = assembler.Parameter(3);
Node* result = assembler->ToThisValue( Node* result = assembler.ToThisValue(
context, receiver, PrimitiveType::kBoolean, "Boolean.prototype.valueOf"); context, receiver, PrimitiveType::kBoolean, "Boolean.prototype.valueOf");
assembler->Return(result); assembler.Return(result);
} }
} // namespace internal } // namespace internal
......
This diff is collapsed.
...@@ -908,9 +908,10 @@ BUILTIN(DatePrototypeToJson) { ...@@ -908,9 +908,10 @@ BUILTIN(DatePrototypeToJson) {
} }
} }
// static namespace {
void Builtins::Generate_DatePrototype_GetField(CodeStubAssembler* assembler,
int field_index) { void Generate_DatePrototype_GetField(CodeStubAssembler* assembler,
int field_index) {
typedef CodeStubAssembler::Label Label; typedef CodeStubAssembler::Label Label;
typedef compiler::Node Node; typedef compiler::Node Node;
...@@ -965,100 +966,132 @@ void Builtins::Generate_DatePrototype_GetField(CodeStubAssembler* assembler, ...@@ -965,100 +966,132 @@ void Builtins::Generate_DatePrototype_GetField(CodeStubAssembler* assembler,
} }
} }
} // namespace
// static // static
void Builtins::Generate_DatePrototypeGetDate(CodeStubAssembler* assembler) { void Builtins::Generate_DatePrototypeGetDate(
Generate_DatePrototype_GetField(assembler, JSDate::kDay); compiler::CodeAssemblerState* state) {
CodeStubAssembler assembler(state);
Generate_DatePrototype_GetField(&assembler, JSDate::kDay);
} }
// static // static
void Builtins::Generate_DatePrototypeGetDay(CodeStubAssembler* assembler) { void Builtins::Generate_DatePrototypeGetDay(
Generate_DatePrototype_GetField(assembler, JSDate::kWeekday); compiler::CodeAssemblerState* state) {
CodeStubAssembler assembler(state);
Generate_DatePrototype_GetField(&assembler, JSDate::kWeekday);
} }
// static // static
void Builtins::Generate_DatePrototypeGetFullYear(CodeStubAssembler* assembler) { void Builtins::Generate_DatePrototypeGetFullYear(
Generate_DatePrototype_GetField(assembler, JSDate::kYear); compiler::CodeAssemblerState* state) {
CodeStubAssembler assembler(state);
Generate_DatePrototype_GetField(&assembler, JSDate::kYear);
} }
// static // static
void Builtins::Generate_DatePrototypeGetHours(CodeStubAssembler* assembler) { void Builtins::Generate_DatePrototypeGetHours(
Generate_DatePrototype_GetField(assembler, JSDate::kHour); compiler::CodeAssemblerState* state) {
CodeStubAssembler assembler(state);
Generate_DatePrototype_GetField(&assembler, JSDate::kHour);
} }
// static // static
void Builtins::Generate_DatePrototypeGetMilliseconds( void Builtins::Generate_DatePrototypeGetMilliseconds(
CodeStubAssembler* assembler) { compiler::CodeAssemblerState* state) {
Generate_DatePrototype_GetField(assembler, JSDate::kMillisecond); CodeStubAssembler assembler(state);
Generate_DatePrototype_GetField(&assembler, JSDate::kMillisecond);
} }
// static // static
void Builtins::Generate_DatePrototypeGetMinutes(CodeStubAssembler* assembler) { void Builtins::Generate_DatePrototypeGetMinutes(
Generate_DatePrototype_GetField(assembler, JSDate::kMinute); compiler::CodeAssemblerState* state) {
CodeStubAssembler assembler(state);
Generate_DatePrototype_GetField(&assembler, JSDate::kMinute);
} }
// static // static
void Builtins::Generate_DatePrototypeGetMonth(CodeStubAssembler* assembler) { void Builtins::Generate_DatePrototypeGetMonth(
Generate_DatePrototype_GetField(assembler, JSDate::kMonth); compiler::CodeAssemblerState* state) {
CodeStubAssembler assembler(state);
Generate_DatePrototype_GetField(&assembler, JSDate::kMonth);
} }
// static // static
void Builtins::Generate_DatePrototypeGetSeconds(CodeStubAssembler* assembler) { void Builtins::Generate_DatePrototypeGetSeconds(
Generate_DatePrototype_GetField(assembler, JSDate::kSecond); compiler::CodeAssemblerState* state) {
CodeStubAssembler assembler(state);
Generate_DatePrototype_GetField(&assembler, JSDate::kSecond);
} }
// static // static
void Builtins::Generate_DatePrototypeGetTime(CodeStubAssembler* assembler) { void Builtins::Generate_DatePrototypeGetTime(
Generate_DatePrototype_GetField(assembler, JSDate::kDateValue); compiler::CodeAssemblerState* state) {
CodeStubAssembler assembler(state);
Generate_DatePrototype_GetField(&assembler, JSDate::kDateValue);
} }
// static // static
void Builtins::Generate_DatePrototypeGetTimezoneOffset( void Builtins::Generate_DatePrototypeGetTimezoneOffset(
CodeStubAssembler* assembler) { compiler::CodeAssemblerState* state) {
Generate_DatePrototype_GetField(assembler, JSDate::kTimezoneOffset); CodeStubAssembler assembler(state);
Generate_DatePrototype_GetField(&assembler, JSDate::kTimezoneOffset);
} }
// static // static
void Builtins::Generate_DatePrototypeGetUTCDate(CodeStubAssembler* assembler) { void Builtins::Generate_DatePrototypeGetUTCDate(
Generate_DatePrototype_GetField(assembler, JSDate::kDayUTC); compiler::CodeAssemblerState* state) {
CodeStubAssembler assembler(state);
Generate_DatePrototype_GetField(&assembler, JSDate::kDayUTC);
} }
// static // static
void Builtins::Generate_DatePrototypeGetUTCDay(CodeStubAssembler* assembler) { void Builtins::Generate_DatePrototypeGetUTCDay(
Generate_DatePrototype_GetField(assembler, JSDate::kWeekdayUTC); compiler::CodeAssemblerState* state) {
CodeStubAssembler assembler(state);
Generate_DatePrototype_GetField(&assembler, JSDate::kWeekdayUTC);
} }
// static // static
void Builtins::Generate_DatePrototypeGetUTCFullYear( void Builtins::Generate_DatePrototypeGetUTCFullYear(
CodeStubAssembler* assembler) { compiler::CodeAssemblerState* state) {
Generate_DatePrototype_GetField(assembler, JSDate::kYearUTC); CodeStubAssembler assembler(state);
Generate_DatePrototype_GetField(&assembler, JSDate::kYearUTC);
} }
// static // static
void Builtins::Generate_DatePrototypeGetUTCHours(CodeStubAssembler* assembler) { void Builtins::Generate_DatePrototypeGetUTCHours(
Generate_DatePrototype_GetField(assembler, JSDate::kHourUTC); compiler::CodeAssemblerState* state) {
CodeStubAssembler assembler(state);
Generate_DatePrototype_GetField(&assembler, JSDate::kHourUTC);
} }
// static // static
void Builtins::Generate_DatePrototypeGetUTCMilliseconds( void Builtins::Generate_DatePrototypeGetUTCMilliseconds(
CodeStubAssembler* assembler) { compiler::CodeAssemblerState* state) {
Generate_DatePrototype_GetField(assembler, JSDate::kMillisecondUTC); CodeStubAssembler assembler(state);
Generate_DatePrototype_GetField(&assembler, JSDate::kMillisecondUTC);
} }
// static // static
void Builtins::Generate_DatePrototypeGetUTCMinutes( void Builtins::Generate_DatePrototypeGetUTCMinutes(
CodeStubAssembler* assembler) { compiler::CodeAssemblerState* state) {
Generate_DatePrototype_GetField(assembler, JSDate::kMinuteUTC); CodeStubAssembler assembler(state);
Generate_DatePrototype_GetField(&assembler, JSDate::kMinuteUTC);
} }
// static // static
void Builtins::Generate_DatePrototypeGetUTCMonth(CodeStubAssembler* assembler) { void Builtins::Generate_DatePrototypeGetUTCMonth(
Generate_DatePrototype_GetField(assembler, JSDate::kMonthUTC); compiler::CodeAssemblerState* state) {
CodeStubAssembler assembler(state);
Generate_DatePrototype_GetField(&assembler, JSDate::kMonthUTC);
} }
// static // static
void Builtins::Generate_DatePrototypeGetUTCSeconds( void Builtins::Generate_DatePrototypeGetUTCSeconds(
CodeStubAssembler* assembler) { compiler::CodeAssemblerState* state) {
Generate_DatePrototype_GetField(assembler, JSDate::kSecondUTC); CodeStubAssembler assembler(state);
Generate_DatePrototype_GetField(&assembler, JSDate::kSecondUTC);
} }
} // namespace internal } // namespace internal
......
...@@ -283,14 +283,15 @@ BUILTIN(FunctionPrototypeToString) { ...@@ -283,14 +283,15 @@ BUILTIN(FunctionPrototypeToString) {
// ES6 section 19.2.3.6 Function.prototype [ @@hasInstance ] ( V ) // ES6 section 19.2.3.6 Function.prototype [ @@hasInstance ] ( V )
void Builtins::Generate_FunctionPrototypeHasInstance( void Builtins::Generate_FunctionPrototypeHasInstance(
CodeStubAssembler* assembler) { compiler::CodeAssemblerState* state) {
using compiler::Node; using compiler::Node;
CodeStubAssembler assembler(state);
Node* f = assembler->Parameter(0); Node* f = assembler.Parameter(0);
Node* v = assembler->Parameter(1); Node* v = assembler.Parameter(1);
Node* context = assembler->Parameter(4); Node* context = assembler.Parameter(4);
Node* result = assembler->OrdinaryHasInstance(context, f, v); Node* result = assembler.OrdinaryHasInstance(context, f, v);
assembler->Return(result); assembler.Return(result);
} }
} // namespace internal } // namespace internal
......
...@@ -96,20 +96,26 @@ void Generate_GeneratorPrototypeResume( ...@@ -96,20 +96,26 @@ void Generate_GeneratorPrototypeResume(
} // anonymous namespace } // anonymous namespace
// ES6 section 25.3.1.2 Generator.prototype.next ( value ) // ES6 section 25.3.1.2 Generator.prototype.next ( value )
void Builtins::Generate_GeneratorPrototypeNext(CodeStubAssembler* assembler) { void Builtins::Generate_GeneratorPrototypeNext(
Generate_GeneratorPrototypeResume(assembler, JSGeneratorObject::kNext, compiler::CodeAssemblerState* state) {
CodeStubAssembler assembler(state);
Generate_GeneratorPrototypeResume(&assembler, JSGeneratorObject::kNext,
"[Generator].prototype.next"); "[Generator].prototype.next");
} }
// ES6 section 25.3.1.3 Generator.prototype.return ( value ) // ES6 section 25.3.1.3 Generator.prototype.return ( value )
void Builtins::Generate_GeneratorPrototypeReturn(CodeStubAssembler* assembler) { void Builtins::Generate_GeneratorPrototypeReturn(
Generate_GeneratorPrototypeResume(assembler, JSGeneratorObject::kReturn, compiler::CodeAssemblerState* state) {
CodeStubAssembler assembler(state);
Generate_GeneratorPrototypeResume(&assembler, JSGeneratorObject::kReturn,
"[Generator].prototype.return"); "[Generator].prototype.return");
} }
// ES6 section 25.3.1.4 Generator.prototype.throw ( exception ) // ES6 section 25.3.1.4 Generator.prototype.throw ( exception )
void Builtins::Generate_GeneratorPrototypeThrow(CodeStubAssembler* assembler) { void Builtins::Generate_GeneratorPrototypeThrow(
Generate_GeneratorPrototypeResume(assembler, JSGeneratorObject::kThrow, compiler::CodeAssemblerState* state) {
CodeStubAssembler assembler(state);
Generate_GeneratorPrototypeResume(&assembler, JSGeneratorObject::kThrow,
"[Generator].prototype.throw"); "[Generator].prototype.throw");
} }
......
...@@ -101,111 +101,112 @@ BUILTIN(GlobalEval) { ...@@ -101,111 +101,112 @@ BUILTIN(GlobalEval) {
} }
// ES6 section 18.2.2 isFinite ( number ) // ES6 section 18.2.2 isFinite ( number )
void Builtins::Generate_GlobalIsFinite(CodeStubAssembler* assembler) { void Builtins::Generate_GlobalIsFinite(compiler::CodeAssemblerState* state) {
typedef CodeStubAssembler::Label Label; typedef CodeStubAssembler::Label Label;
typedef compiler::Node Node; typedef compiler::Node Node;
typedef CodeStubAssembler::Variable Variable; typedef CodeStubAssembler::Variable Variable;
CodeStubAssembler assembler(state);
Node* context = assembler->Parameter(4); Node* context = assembler.Parameter(4);
Label return_true(assembler), return_false(assembler); Label return_true(&assembler), return_false(&assembler);
// We might need to loop once for ToNumber conversion. // We might need to loop once for ToNumber conversion.
Variable var_num(assembler, MachineRepresentation::kTagged); Variable var_num(&assembler, MachineRepresentation::kTagged);
Label loop(assembler, &var_num); Label loop(&assembler, &var_num);
var_num.Bind(assembler->Parameter(1)); var_num.Bind(assembler.Parameter(1));
assembler->Goto(&loop); assembler.Goto(&loop);
assembler->Bind(&loop); assembler.Bind(&loop);
{ {
// Load the current {num} value. // Load the current {num} value.
Node* num = var_num.value(); Node* num = var_num.value();
// Check if {num} is a Smi or a HeapObject. // Check if {num} is a Smi or a HeapObject.
assembler->GotoIf(assembler->TaggedIsSmi(num), &return_true); assembler.GotoIf(assembler.TaggedIsSmi(num), &return_true);
// Check if {num} is a HeapNumber. // Check if {num} is a HeapNumber.
Label if_numisheapnumber(assembler), Label if_numisheapnumber(&assembler),
if_numisnotheapnumber(assembler, Label::kDeferred); if_numisnotheapnumber(&assembler, Label::kDeferred);
assembler->Branch(assembler->WordEqual(assembler->LoadMap(num), assembler.Branch(assembler.WordEqual(assembler.LoadMap(num),
assembler->HeapNumberMapConstant()), assembler.HeapNumberMapConstant()),
&if_numisheapnumber, &if_numisnotheapnumber); &if_numisheapnumber, &if_numisnotheapnumber);
assembler->Bind(&if_numisheapnumber); assembler.Bind(&if_numisheapnumber);
{ {
// Check if {num} contains a finite, non-NaN value. // Check if {num} contains a finite, non-NaN value.
Node* num_value = assembler->LoadHeapNumberValue(num); Node* num_value = assembler.LoadHeapNumberValue(num);
assembler->BranchIfFloat64IsNaN( assembler.BranchIfFloat64IsNaN(assembler.Float64Sub(num_value, num_value),
assembler->Float64Sub(num_value, num_value), &return_false, &return_false, &return_true);
&return_true);
} }
assembler->Bind(&if_numisnotheapnumber); assembler.Bind(&if_numisnotheapnumber);
{ {
// Need to convert {num} to a Number first. // Need to convert {num} to a Number first.
Callable callable = CodeFactory::NonNumberToNumber(assembler->isolate()); Callable callable = CodeFactory::NonNumberToNumber(assembler.isolate());
var_num.Bind(assembler->CallStub(callable, context, num)); var_num.Bind(assembler.CallStub(callable, context, num));
assembler->Goto(&loop); assembler.Goto(&loop);
} }
} }
assembler->Bind(&return_true); assembler.Bind(&return_true);
assembler->Return(assembler->BooleanConstant(true)); assembler.Return(assembler.BooleanConstant(true));
assembler->Bind(&return_false); assembler.Bind(&return_false);
assembler->Return(assembler->BooleanConstant(false)); assembler.Return(assembler.BooleanConstant(false));
} }
// ES6 section 18.2.3 isNaN ( number ) // ES6 section 18.2.3 isNaN ( number )
void Builtins::Generate_GlobalIsNaN(CodeStubAssembler* assembler) { void Builtins::Generate_GlobalIsNaN(compiler::CodeAssemblerState* state) {
typedef CodeStubAssembler::Label Label; typedef CodeStubAssembler::Label Label;
typedef compiler::Node Node; typedef compiler::Node Node;
typedef CodeStubAssembler::Variable Variable; typedef CodeStubAssembler::Variable Variable;
CodeStubAssembler assembler(state);
Node* context = assembler->Parameter(4); Node* context = assembler.Parameter(4);
Label return_true(assembler), return_false(assembler); Label return_true(&assembler), return_false(&assembler);
// We might need to loop once for ToNumber conversion. // We might need to loop once for ToNumber conversion.
Variable var_num(assembler, MachineRepresentation::kTagged); Variable var_num(&assembler, MachineRepresentation::kTagged);
Label loop(assembler, &var_num); Label loop(&assembler, &var_num);
var_num.Bind(assembler->Parameter(1)); var_num.Bind(assembler.Parameter(1));
assembler->Goto(&loop); assembler.Goto(&loop);
assembler->Bind(&loop); assembler.Bind(&loop);
{ {
// Load the current {num} value. // Load the current {num} value.
Node* num = var_num.value(); Node* num = var_num.value();
// Check if {num} is a Smi or a HeapObject. // Check if {num} is a Smi or a HeapObject.
assembler->GotoIf(assembler->TaggedIsSmi(num), &return_false); assembler.GotoIf(assembler.TaggedIsSmi(num), &return_false);
// Check if {num} is a HeapNumber. // Check if {num} is a HeapNumber.
Label if_numisheapnumber(assembler), Label if_numisheapnumber(&assembler),
if_numisnotheapnumber(assembler, Label::kDeferred); if_numisnotheapnumber(&assembler, Label::kDeferred);
assembler->Branch(assembler->WordEqual(assembler->LoadMap(num), assembler.Branch(assembler.WordEqual(assembler.LoadMap(num),
assembler->HeapNumberMapConstant()), assembler.HeapNumberMapConstant()),
&if_numisheapnumber, &if_numisnotheapnumber); &if_numisheapnumber, &if_numisnotheapnumber);
assembler->Bind(&if_numisheapnumber); assembler.Bind(&if_numisheapnumber);
{ {
// Check if {num} contains a NaN. // Check if {num} contains a NaN.
Node* num_value = assembler->LoadHeapNumberValue(num); Node* num_value = assembler.LoadHeapNumberValue(num);
assembler->BranchIfFloat64IsNaN(num_value, &return_true, &return_false); assembler.BranchIfFloat64IsNaN(num_value, &return_true, &return_false);
} }
assembler->Bind(&if_numisnotheapnumber); assembler.Bind(&if_numisnotheapnumber);
{ {
// Need to convert {num} to a Number first. // Need to convert {num} to a Number first.
Callable callable = CodeFactory::NonNumberToNumber(assembler->isolate()); Callable callable = CodeFactory::NonNumberToNumber(assembler.isolate());
var_num.Bind(assembler->CallStub(callable, context, num)); var_num.Bind(assembler.CallStub(callable, context, num));
assembler->Goto(&loop); assembler.Goto(&loop);
} }
} }
assembler->Bind(&return_true); assembler.Bind(&return_true);
assembler->Return(assembler->BooleanConstant(true)); assembler.Return(assembler.BooleanConstant(true));
assembler->Bind(&return_false); assembler.Bind(&return_false);
assembler->Return(assembler->BooleanConstant(false)); assembler.Return(assembler.BooleanConstant(false));
} }
} // namespace internal } // namespace internal
......
...@@ -12,18 +12,19 @@ namespace v8 { ...@@ -12,18 +12,19 @@ namespace v8 {
namespace internal { namespace internal {
void Builtins::Generate_KeyedLoadIC_Megamorphic_TF( void Builtins::Generate_KeyedLoadIC_Megamorphic_TF(
CodeStubAssembler* assembler) { compiler::CodeAssemblerState* state) {
typedef compiler::Node Node; typedef compiler::Node Node;
typedef LoadWithVectorDescriptor Descriptor; typedef LoadWithVectorDescriptor Descriptor;
CodeStubAssembler assembler(state);
Node* receiver = assembler->Parameter(Descriptor::kReceiver); Node* receiver = assembler.Parameter(Descriptor::kReceiver);
Node* name = assembler->Parameter(Descriptor::kName); Node* name = assembler.Parameter(Descriptor::kName);
Node* slot = assembler->Parameter(Descriptor::kSlot); Node* slot = assembler.Parameter(Descriptor::kSlot);
Node* vector = assembler->Parameter(Descriptor::kVector); Node* vector = assembler.Parameter(Descriptor::kVector);
Node* context = assembler->Parameter(Descriptor::kContext); Node* context = assembler.Parameter(Descriptor::kContext);
CodeStubAssembler::LoadICParameters p(context, receiver, name, slot, vector); CodeStubAssembler::LoadICParameters p(context, receiver, name, slot, vector);
assembler->KeyedLoadICGeneric(&p); assembler.KeyedLoadICGeneric(&p);
} }
void Builtins::Generate_KeyedLoadIC_Miss(MacroAssembler* masm) { void Builtins::Generate_KeyedLoadIC_Miss(MacroAssembler* masm) {
...@@ -41,30 +42,14 @@ void Builtins::Generate_KeyedStoreIC_Megamorphic_Strict(MacroAssembler* masm) { ...@@ -41,30 +42,14 @@ void Builtins::Generate_KeyedStoreIC_Megamorphic_Strict(MacroAssembler* masm) {
KeyedStoreIC::GenerateMegamorphic(masm, STRICT); KeyedStoreIC::GenerateMegamorphic(masm, STRICT);
} }
void KeyedStoreICMegamorphic(CodeStubAssembler* assembler, LanguageMode mode) {
typedef compiler::Node Node;
typedef StoreWithVectorDescriptor Descriptor;
Node* receiver = assembler->Parameter(Descriptor::kReceiver);
Node* name = assembler->Parameter(Descriptor::kName);
Node* value = assembler->Parameter(Descriptor::kValue);
Node* slot = assembler->Parameter(Descriptor::kSlot);
Node* vector = assembler->Parameter(Descriptor::kVector);
Node* context = assembler->Parameter(Descriptor::kContext);
CodeStubAssembler::StoreICParameters p(context, receiver, name, value, slot,
vector);
KeyedStoreGenericGenerator::Generate(assembler, &p, mode);
}
void Builtins::Generate_KeyedStoreIC_Megamorphic_TF( void Builtins::Generate_KeyedStoreIC_Megamorphic_TF(
CodeStubAssembler* assembler) { compiler::CodeAssemblerState* state) {
KeyedStoreICMegamorphic(assembler, SLOPPY); KeyedStoreGenericGenerator::Generate(state, SLOPPY);
} }
void Builtins::Generate_KeyedStoreIC_Megamorphic_Strict_TF( void Builtins::Generate_KeyedStoreIC_Megamorphic_Strict_TF(
CodeStubAssembler* assembler) { compiler::CodeAssemblerState* state) {
KeyedStoreICMegamorphic(assembler, STRICT); KeyedStoreGenericGenerator::Generate(state, STRICT);
} }
void Builtins::Generate_KeyedStoreIC_Miss(MacroAssembler* masm) { void Builtins::Generate_KeyedStoreIC_Miss(MacroAssembler* masm) {
...@@ -75,76 +60,79 @@ void Builtins::Generate_KeyedStoreIC_Slow(MacroAssembler* masm) { ...@@ -75,76 +60,79 @@ void Builtins::Generate_KeyedStoreIC_Slow(MacroAssembler* masm) {
KeyedStoreIC::GenerateSlow(masm); KeyedStoreIC::GenerateSlow(masm);
} }
void Builtins::Generate_LoadGlobalIC_Miss(CodeStubAssembler* assembler) { void Builtins::Generate_LoadGlobalIC_Miss(compiler::CodeAssemblerState* state) {
typedef compiler::Node Node; typedef compiler::Node Node;
typedef LoadGlobalWithVectorDescriptor Descriptor; typedef LoadGlobalWithVectorDescriptor Descriptor;
CodeStubAssembler assembler(state);
Node* slot = assembler->Parameter(Descriptor::kSlot); Node* slot = assembler.Parameter(Descriptor::kSlot);
Node* vector = assembler->Parameter(Descriptor::kVector); Node* vector = assembler.Parameter(Descriptor::kVector);
Node* context = assembler->Parameter(Descriptor::kContext); Node* context = assembler.Parameter(Descriptor::kContext);
assembler->TailCallRuntime(Runtime::kLoadGlobalIC_Miss, context, slot, assembler.TailCallRuntime(Runtime::kLoadGlobalIC_Miss, context, slot, vector);
vector);
} }
void Builtins::Generate_LoadGlobalIC_Slow(CodeStubAssembler* assembler) { void Builtins::Generate_LoadGlobalIC_Slow(compiler::CodeAssemblerState* state) {
typedef compiler::Node Node; typedef compiler::Node Node;
typedef LoadGlobalWithVectorDescriptor Descriptor; typedef LoadGlobalWithVectorDescriptor Descriptor;
CodeStubAssembler assembler(state);
Node* slot = assembler->Parameter(Descriptor::kSlot); Node* slot = assembler.Parameter(Descriptor::kSlot);
Node* vector = assembler->Parameter(Descriptor::kVector); Node* vector = assembler.Parameter(Descriptor::kVector);
Node* context = assembler->Parameter(Descriptor::kContext); Node* context = assembler.Parameter(Descriptor::kContext);
assembler->TailCallRuntime(Runtime::kLoadGlobalIC_Slow, context, slot, assembler.TailCallRuntime(Runtime::kLoadGlobalIC_Slow, context, slot, vector);
vector);
} }
void Builtins::Generate_LoadIC_Getter_ForDeopt(MacroAssembler* masm) { void Builtins::Generate_LoadIC_Getter_ForDeopt(MacroAssembler* masm) {
NamedLoadHandlerCompiler::GenerateLoadViaGetterForDeopt(masm); NamedLoadHandlerCompiler::GenerateLoadViaGetterForDeopt(masm);
} }
void Builtins::Generate_LoadIC_Miss(CodeStubAssembler* assembler) { void Builtins::Generate_LoadIC_Miss(compiler::CodeAssemblerState* state) {
typedef compiler::Node Node; typedef compiler::Node Node;
typedef LoadWithVectorDescriptor Descriptor; typedef LoadWithVectorDescriptor Descriptor;
CodeStubAssembler assembler(state);
Node* receiver = assembler->Parameter(Descriptor::kReceiver); Node* receiver = assembler.Parameter(Descriptor::kReceiver);
Node* name = assembler->Parameter(Descriptor::kName); Node* name = assembler.Parameter(Descriptor::kName);
Node* slot = assembler->Parameter(Descriptor::kSlot); Node* slot = assembler.Parameter(Descriptor::kSlot);
Node* vector = assembler->Parameter(Descriptor::kVector); Node* vector = assembler.Parameter(Descriptor::kVector);
Node* context = assembler->Parameter(Descriptor::kContext); Node* context = assembler.Parameter(Descriptor::kContext);
assembler->TailCallRuntime(Runtime::kLoadIC_Miss, context, receiver, name, assembler.TailCallRuntime(Runtime::kLoadIC_Miss, context, receiver, name,
slot, vector); slot, vector);
} }
void Builtins::Generate_LoadIC_Normal(MacroAssembler* masm) { void Builtins::Generate_LoadIC_Normal(MacroAssembler* masm) {
LoadIC::GenerateNormal(masm); LoadIC::GenerateNormal(masm);
} }
void Builtins::Generate_LoadIC_Slow(CodeStubAssembler* assembler) { void Builtins::Generate_LoadIC_Slow(compiler::CodeAssemblerState* state) {
typedef compiler::Node Node; typedef compiler::Node Node;
typedef LoadWithVectorDescriptor Descriptor; typedef LoadWithVectorDescriptor Descriptor;
CodeStubAssembler assembler(state);
Node* receiver = assembler->Parameter(Descriptor::kReceiver); Node* receiver = assembler.Parameter(Descriptor::kReceiver);
Node* name = assembler->Parameter(Descriptor::kName); Node* name = assembler.Parameter(Descriptor::kName);
Node* context = assembler->Parameter(Descriptor::kContext); Node* context = assembler.Parameter(Descriptor::kContext);
assembler->TailCallRuntime(Runtime::kGetProperty, context, receiver, name); assembler.TailCallRuntime(Runtime::kGetProperty, context, receiver, name);
} }
void Builtins::Generate_StoreIC_Miss(CodeStubAssembler* assembler) { void Builtins::Generate_StoreIC_Miss(compiler::CodeAssemblerState* state) {
typedef compiler::Node Node; typedef compiler::Node Node;
typedef StoreWithVectorDescriptor Descriptor; typedef StoreWithVectorDescriptor Descriptor;
CodeStubAssembler assembler(state);
Node* receiver = assembler->Parameter(Descriptor::kReceiver); Node* receiver = assembler.Parameter(Descriptor::kReceiver);
Node* name = assembler->Parameter(Descriptor::kName); Node* name = assembler.Parameter(Descriptor::kName);
Node* value = assembler->Parameter(Descriptor::kValue); Node* value = assembler.Parameter(Descriptor::kValue);
Node* slot = assembler->Parameter(Descriptor::kSlot); Node* slot = assembler.Parameter(Descriptor::kSlot);
Node* vector = assembler->Parameter(Descriptor::kVector); Node* vector = assembler.Parameter(Descriptor::kVector);
Node* context = assembler->Parameter(Descriptor::kContext); Node* context = assembler.Parameter(Descriptor::kContext);
assembler->TailCallRuntime(Runtime::kStoreIC_Miss, context, value, slot, assembler.TailCallRuntime(Runtime::kStoreIC_Miss, context, value, slot,
vector, receiver, name); vector, receiver, name);
} }
void Builtins::Generate_StoreIC_Normal(MacroAssembler* masm) { void Builtins::Generate_StoreIC_Normal(MacroAssembler* masm) {
...@@ -156,30 +144,33 @@ void Builtins::Generate_StoreIC_Setter_ForDeopt(MacroAssembler* masm) { ...@@ -156,30 +144,33 @@ void Builtins::Generate_StoreIC_Setter_ForDeopt(MacroAssembler* masm) {
} }
namespace { namespace {
void Generate_StoreIC_Slow(CodeStubAssembler* assembler, void Generate_StoreIC_Slow(compiler::CodeAssemblerState* state,
LanguageMode language_mode) { LanguageMode language_mode) {
typedef compiler::Node Node; typedef compiler::Node Node;
typedef StoreWithVectorDescriptor Descriptor; typedef StoreWithVectorDescriptor Descriptor;
CodeStubAssembler assembler(state);
Node* receiver = assembler->Parameter(Descriptor::kReceiver); Node* receiver = assembler.Parameter(Descriptor::kReceiver);
Node* name = assembler->Parameter(Descriptor::kName); Node* name = assembler.Parameter(Descriptor::kName);
Node* value = assembler->Parameter(Descriptor::kValue); Node* value = assembler.Parameter(Descriptor::kValue);
Node* context = assembler->Parameter(Descriptor::kContext); Node* context = assembler.Parameter(Descriptor::kContext);
Node* lang_mode = assembler->SmiConstant(Smi::FromInt(language_mode)); Node* lang_mode = assembler.SmiConstant(Smi::FromInt(language_mode));
// The slow case calls into the runtime to complete the store without causing // The slow case calls into the runtime to complete the store without causing
// an IC miss that would otherwise cause a transition to the generic stub. // an IC miss that would otherwise cause a transition to the generic stub.
assembler->TailCallRuntime(Runtime::kSetProperty, context, receiver, name, assembler.TailCallRuntime(Runtime::kSetProperty, context, receiver, name,
value, lang_mode); value, lang_mode);
} }
} // anonymous namespace } // anonymous namespace
void Builtins::Generate_StoreIC_SlowSloppy(CodeStubAssembler* assembler) { void Builtins::Generate_StoreIC_SlowSloppy(
Generate_StoreIC_Slow(assembler, SLOPPY); compiler::CodeAssemblerState* state) {
Generate_StoreIC_Slow(state, SLOPPY);
} }
void Builtins::Generate_StoreIC_SlowStrict(CodeStubAssembler* assembler) { void Builtins::Generate_StoreIC_SlowStrict(
Generate_StoreIC_Slow(assembler, STRICT); compiler::CodeAssemblerState* state) {
Generate_StoreIC_Slow(state, STRICT);
} }
} // namespace internal } // namespace internal
......
...@@ -54,86 +54,90 @@ void Builtins::Generate_StackCheck(MacroAssembler* masm) { ...@@ -54,86 +54,90 @@ void Builtins::Generate_StackCheck(MacroAssembler* masm) {
// TurboFan support builtins. // TurboFan support builtins.
void Builtins::Generate_CopyFastSmiOrObjectElements( void Builtins::Generate_CopyFastSmiOrObjectElements(
CodeStubAssembler* assembler) { compiler::CodeAssemblerState* state) {
typedef CodeStubAssembler::Label Label; typedef CodeStubAssembler::Label Label;
typedef compiler::Node Node; typedef compiler::Node Node;
typedef CopyFastSmiOrObjectElementsDescriptor Descriptor; typedef CopyFastSmiOrObjectElementsDescriptor Descriptor;
CodeStubAssembler assembler(state);
Node* object = assembler->Parameter(Descriptor::kObject); Node* object = assembler.Parameter(Descriptor::kObject);
// Load the {object}s elements. // Load the {object}s elements.
Node* source = assembler->LoadObjectField(object, JSObject::kElementsOffset); Node* source = assembler.LoadObjectField(object, JSObject::kElementsOffset);
CodeStubAssembler::ParameterMode mode = assembler->OptimalParameterMode(); CodeStubAssembler::ParameterMode mode = assembler.OptimalParameterMode();
Node* length = assembler->UntagParameter( Node* length = assembler.UntagParameter(
assembler->LoadFixedArrayBaseLength(source), mode); assembler.LoadFixedArrayBaseLength(source), mode);
// Check if we can allocate in new space. // Check if we can allocate in new space.
ElementsKind kind = FAST_ELEMENTS; ElementsKind kind = FAST_ELEMENTS;
int max_elements = FixedArrayBase::GetMaxLengthForNewSpaceAllocation(kind); int max_elements = FixedArrayBase::GetMaxLengthForNewSpaceAllocation(kind);
Label if_newspace(assembler), if_oldspace(assembler); Label if_newspace(&assembler), if_oldspace(&assembler);
assembler->Branch( assembler.Branch(
assembler->UintPtrLessThan( assembler.UintPtrLessThan(
length, assembler->IntPtrOrSmiConstant(max_elements, mode)), length, assembler.IntPtrOrSmiConstant(max_elements, mode)),
&if_newspace, &if_oldspace); &if_newspace, &if_oldspace);
assembler->Bind(&if_newspace); assembler.Bind(&if_newspace);
{ {
Node* target = assembler->AllocateFixedArray(kind, length, mode); Node* target = assembler.AllocateFixedArray(kind, length, mode);
assembler->CopyFixedArrayElements(kind, source, target, length, assembler.CopyFixedArrayElements(kind, source, target, length,
SKIP_WRITE_BARRIER, mode); SKIP_WRITE_BARRIER, mode);
assembler->StoreObjectField(object, JSObject::kElementsOffset, target); assembler.StoreObjectField(object, JSObject::kElementsOffset, target);
assembler->Return(target); assembler.Return(target);
} }
assembler->Bind(&if_oldspace); assembler.Bind(&if_oldspace);
{ {
Node* target = assembler->AllocateFixedArray( Node* target = assembler.AllocateFixedArray(kind, length, mode,
kind, length, mode, CodeStubAssembler::kPretenured); CodeStubAssembler::kPretenured);
assembler->CopyFixedArrayElements(kind, source, target, length, assembler.CopyFixedArrayElements(kind, source, target, length,
UPDATE_WRITE_BARRIER, mode); UPDATE_WRITE_BARRIER, mode);
assembler->StoreObjectField(object, JSObject::kElementsOffset, target); assembler.StoreObjectField(object, JSObject::kElementsOffset, target);
assembler->Return(target); assembler.Return(target);
} }
} }
void Builtins::Generate_GrowFastDoubleElements(CodeStubAssembler* assembler) { void Builtins::Generate_GrowFastDoubleElements(
compiler::CodeAssemblerState* state) {
typedef CodeStubAssembler::Label Label; typedef CodeStubAssembler::Label Label;
typedef compiler::Node Node; typedef compiler::Node Node;
typedef GrowArrayElementsDescriptor Descriptor; typedef GrowArrayElementsDescriptor Descriptor;
CodeStubAssembler assembler(state);
Node* object = assembler->Parameter(Descriptor::kObject); Node* object = assembler.Parameter(Descriptor::kObject);
Node* key = assembler->Parameter(Descriptor::kKey); Node* key = assembler.Parameter(Descriptor::kKey);
Node* context = assembler->Parameter(Descriptor::kContext); Node* context = assembler.Parameter(Descriptor::kContext);
Label runtime(assembler, CodeStubAssembler::Label::kDeferred); Label runtime(&assembler, CodeStubAssembler::Label::kDeferred);
Node* elements = assembler->LoadElements(object); Node* elements = assembler.LoadElements(object);
elements = assembler->TryGrowElementsCapacity( elements = assembler.TryGrowElementsCapacity(
object, elements, FAST_DOUBLE_ELEMENTS, key, &runtime); object, elements, FAST_DOUBLE_ELEMENTS, key, &runtime);
assembler->Return(elements); assembler.Return(elements);
assembler->Bind(&runtime); assembler.Bind(&runtime);
assembler->TailCallRuntime(Runtime::kGrowArrayElements, context, object, key); assembler.TailCallRuntime(Runtime::kGrowArrayElements, context, object, key);
} }
void Builtins::Generate_GrowFastSmiOrObjectElements( void Builtins::Generate_GrowFastSmiOrObjectElements(
CodeStubAssembler* assembler) { compiler::CodeAssemblerState* state) {
typedef CodeStubAssembler::Label Label; typedef CodeStubAssembler::Label Label;
typedef compiler::Node Node; typedef compiler::Node Node;
typedef GrowArrayElementsDescriptor Descriptor; typedef GrowArrayElementsDescriptor Descriptor;
CodeStubAssembler assembler(state);
Node* object = assembler->Parameter(Descriptor::kObject); Node* object = assembler.Parameter(Descriptor::kObject);
Node* key = assembler->Parameter(Descriptor::kKey); Node* key = assembler.Parameter(Descriptor::kKey);
Node* context = assembler->Parameter(Descriptor::kContext); Node* context = assembler.Parameter(Descriptor::kContext);
Label runtime(assembler, CodeStubAssembler::Label::kDeferred); Label runtime(&assembler, CodeStubAssembler::Label::kDeferred);
Node* elements = assembler->LoadElements(object); Node* elements = assembler.LoadElements(object);
elements = assembler->TryGrowElementsCapacity(object, elements, FAST_ELEMENTS, elements = assembler.TryGrowElementsCapacity(object, elements, FAST_ELEMENTS,
key, &runtime); key, &runtime);
assembler->Return(elements); assembler.Return(elements);
assembler->Bind(&runtime); assembler.Bind(&runtime);
assembler->TailCallRuntime(Runtime::kGrowArrayElements, context, object, key); assembler.TailCallRuntime(Runtime::kGrowArrayElements, context, object, key);
} }
} // namespace internal } // namespace internal
......
...@@ -10,8 +10,9 @@ namespace v8 { ...@@ -10,8 +10,9 @@ namespace v8 {
namespace internal { namespace internal {
void Builtins::Generate_IteratorPrototypeIterator( void Builtins::Generate_IteratorPrototypeIterator(
CodeStubAssembler* assembler) { compiler::CodeAssemblerState* state) {
assembler->Return(assembler->Parameter(0)); CodeStubAssembler assembler(state);
assembler.Return(assembler.Parameter(0));
} }
BUILTIN(ModuleNamespaceIterator) { BUILTIN(ModuleNamespaceIterator) {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -31,7 +31,7 @@ void ValidateSharedTypedArray(CodeStubAssembler* a, compiler::Node* tagged, ...@@ -31,7 +31,7 @@ void ValidateSharedTypedArray(CodeStubAssembler* a, compiler::Node* tagged,
compiler::Node* context, compiler::Node* context,
compiler::Node** out_instance_type, compiler::Node** out_instance_type,
compiler::Node** out_backing_store) { compiler::Node** out_backing_store) {
using namespace compiler; using compiler::Node;
CodeStubAssembler::Label is_smi(a), not_smi(a), is_typed_array(a), CodeStubAssembler::Label is_smi(a), not_smi(a), is_typed_array(a),
not_typed_array(a), is_shared(a), not_shared(a), is_float_or_clamped(a), not_typed_array(a), is_shared(a), not_shared(a), is_float_or_clamped(a),
not_float_or_clamped(a), invalid(a); not_float_or_clamped(a), invalid(a);
...@@ -95,7 +95,7 @@ void ValidateSharedTypedArray(CodeStubAssembler* a, compiler::Node* tagged, ...@@ -95,7 +95,7 @@ void ValidateSharedTypedArray(CodeStubAssembler* a, compiler::Node* tagged,
compiler::Node* ConvertTaggedAtomicIndexToWord32(CodeStubAssembler* a, compiler::Node* ConvertTaggedAtomicIndexToWord32(CodeStubAssembler* a,
compiler::Node* tagged, compiler::Node* tagged,
compiler::Node* context) { compiler::Node* context) {
using namespace compiler; using compiler::Node;
CodeStubAssembler::Variable var_result(a, MachineRepresentation::kWord32); CodeStubAssembler::Variable var_result(a, MachineRepresentation::kWord32);
Callable to_number = CodeFactory::ToNumber(a->isolate()); Callable to_number = CodeFactory::ToNumber(a->isolate());
...@@ -139,7 +139,7 @@ compiler::Node* ConvertTaggedAtomicIndexToWord32(CodeStubAssembler* a, ...@@ -139,7 +139,7 @@ compiler::Node* ConvertTaggedAtomicIndexToWord32(CodeStubAssembler* a,
void ValidateAtomicIndex(CodeStubAssembler* a, compiler::Node* index_word, void ValidateAtomicIndex(CodeStubAssembler* a, compiler::Node* index_word,
compiler::Node* array_length_word, compiler::Node* array_length_word,
compiler::Node* context) { compiler::Node* context) {
using namespace compiler; using compiler::Node;
// Check if the index is in bounds. If not, throw RangeError. // Check if the index is in bounds. If not, throw RangeError.
CodeStubAssembler::Label if_inbounds(a), if_notinbounds(a); CodeStubAssembler::Label if_inbounds(a), if_notinbounds(a);
// TODO(jkummerow): Use unsigned comparison instead of "i<0 || i>length". // TODO(jkummerow): Use unsigned comparison instead of "i<0 || i>length".
...@@ -155,24 +155,25 @@ void ValidateAtomicIndex(CodeStubAssembler* a, compiler::Node* index_word, ...@@ -155,24 +155,25 @@ void ValidateAtomicIndex(CodeStubAssembler* a, compiler::Node* index_word,
} // anonymous namespace } // anonymous namespace
void Builtins::Generate_AtomicsLoad(CodeStubAssembler* a) { void Builtins::Generate_AtomicsLoad(compiler::CodeAssemblerState* state) {
using namespace compiler; using compiler::Node;
Node* array = a->Parameter(1); CodeStubAssembler a(state);
Node* index = a->Parameter(2); Node* array = a.Parameter(1);
Node* context = a->Parameter(3 + 2); Node* index = a.Parameter(2);
Node* context = a.Parameter(3 + 2);
Node* instance_type; Node* instance_type;
Node* backing_store; Node* backing_store;
ValidateSharedTypedArray(a, array, context, &instance_type, &backing_store); ValidateSharedTypedArray(&a, array, context, &instance_type, &backing_store);
Node* index_word32 = ConvertTaggedAtomicIndexToWord32(a, index, context); Node* index_word32 = ConvertTaggedAtomicIndexToWord32(&a, index, context);
Node* array_length_word32 = a->TruncateTaggedToWord32( Node* array_length_word32 = a.TruncateTaggedToWord32(
context, a->LoadObjectField(array, JSTypedArray::kLengthOffset)); context, a.LoadObjectField(array, JSTypedArray::kLengthOffset));
ValidateAtomicIndex(a, index_word32, array_length_word32, context); ValidateAtomicIndex(&a, index_word32, array_length_word32, context);
Node* index_word = a->ChangeUint32ToWord(index_word32); Node* index_word = a.ChangeUint32ToWord(index_word32);
CodeStubAssembler::Label i8(a), u8(a), i16(a), u16(a), i32(a), u32(a), CodeStubAssembler::Label i8(&a), u8(&a), i16(&a), u16(&a), i32(&a), u32(&a),
other(a); other(&a);
int32_t case_values[] = { int32_t case_values[] = {
FIXED_INT8_ARRAY_TYPE, FIXED_UINT8_ARRAY_TYPE, FIXED_INT16_ARRAY_TYPE, FIXED_INT8_ARRAY_TYPE, FIXED_UINT8_ARRAY_TYPE, FIXED_INT16_ARRAY_TYPE,
FIXED_UINT16_ARRAY_TYPE, FIXED_INT32_ARRAY_TYPE, FIXED_UINT32_ARRAY_TYPE, FIXED_UINT16_ARRAY_TYPE, FIXED_INT32_ARRAY_TYPE, FIXED_UINT32_ARRAY_TYPE,
...@@ -180,59 +181,60 @@ void Builtins::Generate_AtomicsLoad(CodeStubAssembler* a) { ...@@ -180,59 +181,60 @@ void Builtins::Generate_AtomicsLoad(CodeStubAssembler* a) {
CodeStubAssembler::Label* case_labels[] = { CodeStubAssembler::Label* case_labels[] = {
&i8, &u8, &i16, &u16, &i32, &u32, &i8, &u8, &i16, &u16, &i32, &u32,
}; };
a->Switch(instance_type, &other, case_values, case_labels, a.Switch(instance_type, &other, case_values, case_labels,
arraysize(case_labels)); arraysize(case_labels));
a->Bind(&i8); a.Bind(&i8);
a->Return( a.Return(
a->SmiTag(a->AtomicLoad(MachineType::Int8(), backing_store, index_word))); a.SmiTag(a.AtomicLoad(MachineType::Int8(), backing_store, index_word)));
a->Bind(&u8); a.Bind(&u8);
a->Return(a->SmiTag( a.Return(
a->AtomicLoad(MachineType::Uint8(), backing_store, index_word))); a.SmiTag(a.AtomicLoad(MachineType::Uint8(), backing_store, index_word)));
a->Bind(&i16); a.Bind(&i16);
a->Return(a->SmiTag(a->AtomicLoad(MachineType::Int16(), backing_store, a.Return(a.SmiTag(a.AtomicLoad(MachineType::Int16(), backing_store,
a->WordShl(index_word, 1)))); a.WordShl(index_word, 1))));
a->Bind(&u16); a.Bind(&u16);
a->Return(a->SmiTag(a->AtomicLoad(MachineType::Uint16(), backing_store, a.Return(a.SmiTag(a.AtomicLoad(MachineType::Uint16(), backing_store,
a->WordShl(index_word, 1)))); a.WordShl(index_word, 1))));
a->Bind(&i32); a.Bind(&i32);
a->Return(a->ChangeInt32ToTagged(a->AtomicLoad( a.Return(a.ChangeInt32ToTagged(a.AtomicLoad(
MachineType::Int32(), backing_store, a->WordShl(index_word, 2)))); MachineType::Int32(), backing_store, a.WordShl(index_word, 2))));
a->Bind(&u32); a.Bind(&u32);
a->Return(a->ChangeUint32ToTagged(a->AtomicLoad( a.Return(a.ChangeUint32ToTagged(a.AtomicLoad(
MachineType::Uint32(), backing_store, a->WordShl(index_word, 2)))); MachineType::Uint32(), backing_store, a.WordShl(index_word, 2))));
// This shouldn't happen, we've already validated the type. // This shouldn't happen, we've already validated the type.
a->Bind(&other); a.Bind(&other);
a->Return(a->Int32Constant(0)); a.Return(a.Int32Constant(0));
} }
void Builtins::Generate_AtomicsStore(CodeStubAssembler* a) { void Builtins::Generate_AtomicsStore(compiler::CodeAssemblerState* state) {
using namespace compiler; using compiler::Node;
Node* array = a->Parameter(1); CodeStubAssembler a(state);
Node* index = a->Parameter(2); Node* array = a.Parameter(1);
Node* value = a->Parameter(3); Node* index = a.Parameter(2);
Node* context = a->Parameter(4 + 2); Node* value = a.Parameter(3);
Node* context = a.Parameter(4 + 2);
Node* instance_type; Node* instance_type;
Node* backing_store; Node* backing_store;
ValidateSharedTypedArray(a, array, context, &instance_type, &backing_store); ValidateSharedTypedArray(&a, array, context, &instance_type, &backing_store);
Node* index_word32 = ConvertTaggedAtomicIndexToWord32(a, index, context); Node* index_word32 = ConvertTaggedAtomicIndexToWord32(&a, index, context);
Node* array_length_word32 = a->TruncateTaggedToWord32( Node* array_length_word32 = a.TruncateTaggedToWord32(
context, a->LoadObjectField(array, JSTypedArray::kLengthOffset)); context, a.LoadObjectField(array, JSTypedArray::kLengthOffset));
ValidateAtomicIndex(a, index_word32, array_length_word32, context); ValidateAtomicIndex(&a, index_word32, array_length_word32, context);
Node* index_word = a->ChangeUint32ToWord(index_word32); Node* index_word = a.ChangeUint32ToWord(index_word32);
Node* value_integer = a->ToInteger(context, value); Node* value_integer = a.ToInteger(context, value);
Node* value_word32 = a->TruncateTaggedToWord32(context, value_integer); Node* value_word32 = a.TruncateTaggedToWord32(context, value_integer);
CodeStubAssembler::Label u8(a), u16(a), u32(a), other(a); CodeStubAssembler::Label u8(&a), u16(&a), u32(&a), other(&a);
int32_t case_values[] = { int32_t case_values[] = {
FIXED_INT8_ARRAY_TYPE, FIXED_UINT8_ARRAY_TYPE, FIXED_INT16_ARRAY_TYPE, FIXED_INT8_ARRAY_TYPE, FIXED_UINT8_ARRAY_TYPE, FIXED_INT16_ARRAY_TYPE,
FIXED_UINT16_ARRAY_TYPE, FIXED_INT32_ARRAY_TYPE, FIXED_UINT32_ARRAY_TYPE, FIXED_UINT16_ARRAY_TYPE, FIXED_INT32_ARRAY_TYPE, FIXED_UINT32_ARRAY_TYPE,
...@@ -240,27 +242,27 @@ void Builtins::Generate_AtomicsStore(CodeStubAssembler* a) { ...@@ -240,27 +242,27 @@ void Builtins::Generate_AtomicsStore(CodeStubAssembler* a) {
CodeStubAssembler::Label* case_labels[] = { CodeStubAssembler::Label* case_labels[] = {
&u8, &u8, &u16, &u16, &u32, &u32, &u8, &u8, &u16, &u16, &u32, &u32,
}; };
a->Switch(instance_type, &other, case_values, case_labels, a.Switch(instance_type, &other, case_values, case_labels,
arraysize(case_labels)); arraysize(case_labels));
a->Bind(&u8); a.Bind(&u8);
a->AtomicStore(MachineRepresentation::kWord8, backing_store, index_word, a.AtomicStore(MachineRepresentation::kWord8, backing_store, index_word,
value_word32); value_word32);
a->Return(value_integer); a.Return(value_integer);
a->Bind(&u16); a.Bind(&u16);
a->AtomicStore(MachineRepresentation::kWord16, backing_store, a.AtomicStore(MachineRepresentation::kWord16, backing_store,
a->WordShl(index_word, 1), value_word32); a.WordShl(index_word, 1), value_word32);
a->Return(value_integer); a.Return(value_integer);
a->Bind(&u32); a.Bind(&u32);
a->AtomicStore(MachineRepresentation::kWord32, backing_store, a.AtomicStore(MachineRepresentation::kWord32, backing_store,
a->WordShl(index_word, 2), value_word32); a.WordShl(index_word, 2), value_word32);
a->Return(value_integer); a.Return(value_integer);
// This shouldn't happen, we've already validated the type. // This shouldn't happen, we've already validated the type.
a->Bind(&other); a.Bind(&other);
a->Return(a->Int32Constant(0)); a.Return(a.Int32Constant(0));
} }
} // namespace internal } // namespace internal
......
This diff is collapsed.
...@@ -34,42 +34,47 @@ BUILTIN(SymbolConstructor_ConstructStub) { ...@@ -34,42 +34,47 @@ BUILTIN(SymbolConstructor_ConstructStub) {
// ES6 section 19.4.3.4 Symbol.prototype [ @@toPrimitive ] ( hint ) // ES6 section 19.4.3.4 Symbol.prototype [ @@toPrimitive ] ( hint )
void Builtins::Generate_SymbolPrototypeToPrimitive( void Builtins::Generate_SymbolPrototypeToPrimitive(
CodeStubAssembler* assembler) { compiler::CodeAssemblerState* state) {
typedef compiler::Node Node; typedef compiler::Node Node;
CodeStubAssembler assembler(state);
Node* receiver = assembler->Parameter(0); Node* receiver = assembler.Parameter(0);
Node* context = assembler->Parameter(4); Node* context = assembler.Parameter(4);
Node* result = Node* result =
assembler->ToThisValue(context, receiver, PrimitiveType::kSymbol, assembler.ToThisValue(context, receiver, PrimitiveType::kSymbol,
"Symbol.prototype [ @@toPrimitive ]"); "Symbol.prototype [ @@toPrimitive ]");
assembler->Return(result); assembler.Return(result);
} }
// ES6 section 19.4.3.2 Symbol.prototype.toString ( ) // ES6 section 19.4.3.2 Symbol.prototype.toString ( )
void Builtins::Generate_SymbolPrototypeToString(CodeStubAssembler* assembler) { void Builtins::Generate_SymbolPrototypeToString(
compiler::CodeAssemblerState* state) {
typedef compiler::Node Node; typedef compiler::Node Node;
CodeStubAssembler assembler(state);
Node* receiver = assembler->Parameter(0); Node* receiver = assembler.Parameter(0);
Node* context = assembler->Parameter(3); Node* context = assembler.Parameter(3);
Node* value = assembler->ToThisValue( Node* value = assembler.ToThisValue(context, receiver, PrimitiveType::kSymbol,
context, receiver, PrimitiveType::kSymbol, "Symbol.prototype.toString"); "Symbol.prototype.toString");
Node* result = Node* result =
assembler->CallRuntime(Runtime::kSymbolDescriptiveString, context, value); assembler.CallRuntime(Runtime::kSymbolDescriptiveString, context, value);
assembler->Return(result); assembler.Return(result);
} }
// ES6 section 19.4.3.3 Symbol.prototype.valueOf ( ) // ES6 section 19.4.3.3 Symbol.prototype.valueOf ( )
void Builtins::Generate_SymbolPrototypeValueOf(CodeStubAssembler* assembler) { void Builtins::Generate_SymbolPrototypeValueOf(
compiler::CodeAssemblerState* state) {
typedef compiler::Node Node; typedef compiler::Node Node;
CodeStubAssembler assembler(state);
Node* receiver = assembler->Parameter(0); Node* receiver = assembler.Parameter(0);
Node* context = assembler->Parameter(3); Node* context = assembler.Parameter(3);
Node* result = assembler->ToThisValue( Node* result = assembler.ToThisValue(
context, receiver, PrimitiveType::kSymbol, "Symbol.prototype.valueOf"); context, receiver, PrimitiveType::kSymbol, "Symbol.prototype.valueOf");
assembler->Return(result); assembler.Return(result);
} }
} // namespace internal } // namespace internal
......
This diff is collapsed.
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include "src/builtins/builtins.h" #include "src/builtins/builtins.h"
#include "src/code-events.h" #include "src/code-events.h"
#include "src/code-stub-assembler.h" #include "src/compiler/code-assembler.h"
#include "src/ic/ic-state.h" #include "src/ic/ic-state.h"
#include "src/interface-descriptors.h" #include "src/interface-descriptors.h"
#include "src/isolate.h" #include "src/isolate.h"
...@@ -42,7 +42,7 @@ void PostBuildProfileAndTracing(Isolate* isolate, Code* code, ...@@ -42,7 +42,7 @@ void PostBuildProfileAndTracing(Isolate* isolate, Code* code,
} }
typedef void (*MacroAssemblerGenerator)(MacroAssembler*); typedef void (*MacroAssemblerGenerator)(MacroAssembler*);
typedef void (*CodeAssemblerGenerator)(CodeStubAssembler*); typedef void (*CodeAssemblerGenerator)(compiler::CodeAssemblerState*);
Code* BuildWithMacroAssembler(Isolate* isolate, Code* BuildWithMacroAssembler(Isolate* isolate,
MacroAssemblerGenerator generator, MacroAssemblerGenerator generator,
...@@ -86,9 +86,10 @@ Code* BuildWithCodeStubAssemblerJS(Isolate* isolate, ...@@ -86,9 +86,10 @@ Code* BuildWithCodeStubAssemblerJS(Isolate* isolate,
Zone zone(isolate->allocator(), ZONE_NAME); Zone zone(isolate->allocator(), ZONE_NAME);
const int argc_with_recv = const int argc_with_recv =
(argc == SharedFunctionInfo::kDontAdaptArgumentsSentinel) ? 0 : argc + 1; (argc == SharedFunctionInfo::kDontAdaptArgumentsSentinel) ? 0 : argc + 1;
CodeStubAssembler assembler(isolate, &zone, argc_with_recv, flags, name); compiler::CodeAssemblerState state(isolate, &zone, argc_with_recv, flags,
generator(&assembler); name);
Handle<Code> code = assembler.GenerateCode(); generator(&state);
Handle<Code> code = compiler::CodeAssembler::GenerateCode(&state);
PostBuildProfileAndTracing(isolate, *code, name); PostBuildProfileAndTracing(isolate, *code, name);
return *code; return *code;
} }
...@@ -105,9 +106,9 @@ Code* BuildWithCodeStubAssemblerCS(Isolate* isolate, ...@@ -105,9 +106,9 @@ Code* BuildWithCodeStubAssemblerCS(Isolate* isolate,
CallInterfaceDescriptor descriptor(isolate, interface_descriptor); CallInterfaceDescriptor descriptor(isolate, interface_descriptor);
// Ensure descriptor is already initialized. // Ensure descriptor is already initialized.
DCHECK_LE(0, descriptor.GetRegisterParameterCount()); DCHECK_LE(0, descriptor.GetRegisterParameterCount());
CodeStubAssembler assembler(isolate, &zone, descriptor, flags, name); compiler::CodeAssemblerState state(isolate, &zone, descriptor, flags, name);
generator(&assembler); generator(&state);
Handle<Code> code = assembler.GenerateCode(); Handle<Code> code = compiler::CodeAssembler::GenerateCode(&state);
PostBuildProfileAndTracing(isolate, *code, name); PostBuildProfileAndTracing(isolate, *code, name);
return *code; return *code;
} }
......
...@@ -716,8 +716,10 @@ namespace internal { ...@@ -716,8 +716,10 @@ namespace internal {
IGNORE_BUILTIN, IGNORE_BUILTIN, V) IGNORE_BUILTIN, IGNORE_BUILTIN, V)
// Forward declarations. // Forward declarations.
class CodeStubAssembler;
class ObjectVisitor; class ObjectVisitor;
namespace compiler {
class CodeAssemblerState;
}
class Builtins { class Builtins {
public: public:
...@@ -816,16 +818,13 @@ class Builtins { ...@@ -816,16 +818,13 @@ class Builtins {
static void Generate_InterpreterPushArgsAndConstructImpl( static void Generate_InterpreterPushArgsAndConstructImpl(
MacroAssembler* masm, CallableType function_type); MacroAssembler* masm, CallableType function_type);
static void Generate_DatePrototype_GetField(CodeStubAssembler* masm,
int field_index);
enum class MathMaxMinKind { kMax, kMin }; enum class MathMaxMinKind { kMax, kMin };
static void Generate_MathMaxMin(MacroAssembler* masm, MathMaxMinKind kind); static void Generate_MathMaxMin(MacroAssembler* masm, MathMaxMinKind kind);
#define DECLARE_ASM(Name, ...) \ #define DECLARE_ASM(Name, ...) \
static void Generate_##Name(MacroAssembler* masm); static void Generate_##Name(MacroAssembler* masm);
#define DECLARE_TF(Name, ...) \ #define DECLARE_TF(Name, ...) \
static void Generate_##Name(CodeStubAssembler* csasm); static void Generate_##Name(compiler::CodeAssemblerState* state);
BUILTIN_LIST(IGNORE_BUILTIN, IGNORE_BUILTIN, DECLARE_TF, DECLARE_TF, BUILTIN_LIST(IGNORE_BUILTIN, IGNORE_BUILTIN, DECLARE_TF, DECLARE_TF,
DECLARE_ASM, DECLARE_ASM, DECLARE_ASM) DECLARE_ASM, DECLARE_ASM, DECLARE_ASM)
......
...@@ -13,18 +13,6 @@ namespace internal { ...@@ -13,18 +13,6 @@ namespace internal {
using compiler::Node; using compiler::Node;
CodeStubAssembler::CodeStubAssembler(Isolate* isolate, Zone* zone,
const CallInterfaceDescriptor& descriptor,
Code::Flags flags, const char* name,
size_t result_size)
: compiler::CodeAssembler(isolate, zone, descriptor, flags, name,
result_size) {}
CodeStubAssembler::CodeStubAssembler(Isolate* isolate, Zone* zone,
int parameter_count, Code::Flags flags,
const char* name)
: compiler::CodeAssembler(isolate, zone, parameter_count, flags, name) {}
void CodeStubAssembler::Assert(ConditionBody codition_body, const char* message, void CodeStubAssembler::Assert(ConditionBody codition_body, const char* message,
const char* file, int line) { const char* file, int line) {
#if defined(DEBUG) #if defined(DEBUG)
......
...@@ -44,17 +44,8 @@ enum class PrimitiveType { kBoolean, kNumber, kString, kSymbol }; ...@@ -44,17 +44,8 @@ enum class PrimitiveType { kBoolean, kNumber, kString, kSymbol };
// from a compiler directory OWNER). // from a compiler directory OWNER).
class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler { class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
public: public:
// Create with CallStub linkage. CodeStubAssembler(compiler::CodeAssemblerState* state)
// |result_size| specifies the number of results returned by the stub. : compiler::CodeAssembler(state) {}
// TODO(rmcilroy): move result_size to the CallInterfaceDescriptor.
CodeStubAssembler(Isolate* isolate, Zone* zone,
const CallInterfaceDescriptor& descriptor,
Code::Flags flags, const char* name,
size_t result_size = 1);
// Create with JSCall linkage.
CodeStubAssembler(Isolate* isolate, Zone* zone, int parameter_count,
Code::Flags flags, const char* name);
enum AllocationFlag : uint8_t { enum AllocationFlag : uint8_t {
kNone = 0, kNone = 0,
......
...@@ -251,8 +251,9 @@ Handle<Code> HydrogenCodeStub::GenerateRuntimeTailCall( ...@@ -251,8 +251,9 @@ Handle<Code> HydrogenCodeStub::GenerateRuntimeTailCall(
const char* name = CodeStub::MajorName(MajorKey()); const char* name = CodeStub::MajorName(MajorKey());
Zone zone(isolate()->allocator(), ZONE_NAME); Zone zone(isolate()->allocator(), ZONE_NAME);
CallInterfaceDescriptor interface_descriptor(GetCallInterfaceDescriptor()); CallInterfaceDescriptor interface_descriptor(GetCallInterfaceDescriptor());
CodeStubAssembler assembler(isolate(), &zone, interface_descriptor, compiler::CodeAssemblerState state(isolate(), &zone, interface_descriptor,
GetCodeFlags(), name); GetCodeFlags(), name);
CodeStubAssembler assembler(&state);
int total_params = interface_descriptor.GetStackParameterCount() + int total_params = interface_descriptor.GetStackParameterCount() +
interface_descriptor.GetRegisterParameterCount(); interface_descriptor.GetRegisterParameterCount();
switch (total_params) { switch (total_params) {
...@@ -284,7 +285,7 @@ Handle<Code> HydrogenCodeStub::GenerateRuntimeTailCall( ...@@ -284,7 +285,7 @@ Handle<Code> HydrogenCodeStub::GenerateRuntimeTailCall(
UNIMPLEMENTED(); UNIMPLEMENTED();
break; break;
} }
return assembler.GenerateCode(); return compiler::CodeAssembler::GenerateCode(&state);
} }
template <class Stub> template <class Stub>
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "src/handles-inl.h" #include "src/handles-inl.h"
#include "src/objects.h" // For FAA::LoadInternalField impl. #include "src/objects.h" // For FAA::LoadInternalField impl.
using v8::internal::CodeStubAssembler;
using v8::internal::compiler::Node; using v8::internal::compiler::Node;
namespace v8 { namespace v8 {
...@@ -19,9 +18,9 @@ namespace internal { ...@@ -19,9 +18,9 @@ namespace internal {
FastAccessorAssembler::FastAccessorAssembler(Isolate* isolate) FastAccessorAssembler::FastAccessorAssembler(Isolate* isolate)
: zone_(isolate->allocator(), ZONE_NAME), : zone_(isolate->allocator(), ZONE_NAME),
isolate_(isolate), isolate_(isolate),
assembler_(new CodeStubAssembler(isolate, zone(), 1, assembler_state_(isolate, zone(), 1, Code::ComputeFlags(Code::STUB),
Code::ComputeFlags(Code::STUB), "FastAccessorAssembler"),
"FastAccessorAssembler")), assembler_(new CodeStubAssembler(&assembler_state_)),
state_(kBuilding) {} state_(kBuilding) {}
FastAccessorAssembler::~FastAccessorAssembler() { Clear(); } FastAccessorAssembler::~FastAccessorAssembler() { Clear(); }
...@@ -248,7 +247,7 @@ void FastAccessorAssembler::CheckIsJSObjectOrJump(ValueId value_id, ...@@ -248,7 +247,7 @@ void FastAccessorAssembler::CheckIsJSObjectOrJump(ValueId value_id,
MaybeHandle<Code> FastAccessorAssembler::Build() { MaybeHandle<Code> FastAccessorAssembler::Build() {
CHECK_EQ(kBuilding, state_); CHECK_EQ(kBuilding, state_);
Handle<Code> code = assembler_->GenerateCode(); Handle<Code> code = compiler::CodeAssembler::GenerateCode(&assembler_state_);
state_ = !code.is_null() ? kBuilt : kError; state_ = !code.is_null() ? kBuilt : kError;
Clear(); Clear();
return code; return code;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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