Commit 8d2376a1 authored by Ross McIlroy's avatar Ross McIlroy Committed by Commit Bot

[CSA][cleanup] Tnodify builtins-internal-gen

Also Tnodifies TryPrototypeChainLookup.

Bug: v8:9810
Change-Id: I4950ad3bbcfcf3528589d343282517ee0b57e65f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1906375Reviewed-by: 's avatarSantiago Aboy Solanes <solanes@chromium.org>
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64881}
parent 6e90f2f2
...@@ -2067,6 +2067,7 @@ v8_source_set("v8_base_without_compiler") { ...@@ -2067,6 +2067,7 @@ v8_source_set("v8_base_without_compiler") {
"src/codegen/string-constants.h", "src/codegen/string-constants.h",
"src/codegen/tick-counter.cc", "src/codegen/tick-counter.cc",
"src/codegen/tick-counter.h", "src/codegen/tick-counter.h",
"src/codegen/tnode.cc",
"src/codegen/tnode.h", "src/codegen/tnode.h",
"src/codegen/turbo-assembler.cc", "src/codegen/turbo-assembler.cc",
"src/codegen/turbo-assembler.h", "src/codegen/turbo-assembler.h",
......
...@@ -41,9 +41,8 @@ TF_BUILTIN(CopyFastSmiOrObjectElements, CodeStubAssembler) { ...@@ -41,9 +41,8 @@ TF_BUILTIN(CopyFastSmiOrObjectElements, CodeStubAssembler) {
} }
TF_BUILTIN(GrowFastDoubleElements, CodeStubAssembler) { TF_BUILTIN(GrowFastDoubleElements, CodeStubAssembler) {
Node* object = Parameter(Descriptor::kObject); TNode<JSObject> object = CAST(Parameter(Descriptor::kObject));
Node* key = Parameter(Descriptor::kKey); TNode<Number> key = CAST(Parameter(Descriptor::kKey));
Node* context = Parameter(Descriptor::kContext);
Label runtime(this, Label::kDeferred); Label runtime(this, Label::kDeferred);
TNode<FixedArrayBase> elements = LoadElements(object); TNode<FixedArrayBase> elements = LoadElements(object);
...@@ -52,13 +51,13 @@ TF_BUILTIN(GrowFastDoubleElements, CodeStubAssembler) { ...@@ -52,13 +51,13 @@ TF_BUILTIN(GrowFastDoubleElements, CodeStubAssembler) {
Return(elements); Return(elements);
BIND(&runtime); BIND(&runtime);
TailCallRuntime(Runtime::kGrowArrayElements, context, object, key); TailCallRuntime(Runtime::kGrowArrayElements, NoContextConstant(), object,
key);
} }
TF_BUILTIN(GrowFastSmiOrObjectElements, CodeStubAssembler) { TF_BUILTIN(GrowFastSmiOrObjectElements, CodeStubAssembler) {
Node* object = Parameter(Descriptor::kObject); TNode<JSObject> object = CAST(Parameter(Descriptor::kObject));
Node* key = Parameter(Descriptor::kKey); TNode<Number> key = CAST(Parameter(Descriptor::kKey));
Node* context = Parameter(Descriptor::kContext);
Label runtime(this, Label::kDeferred); Label runtime(this, Label::kDeferred);
TNode<FixedArrayBase> elements = LoadElements(object); TNode<FixedArrayBase> elements = LoadElements(object);
...@@ -67,11 +66,12 @@ TF_BUILTIN(GrowFastSmiOrObjectElements, CodeStubAssembler) { ...@@ -67,11 +66,12 @@ TF_BUILTIN(GrowFastSmiOrObjectElements, CodeStubAssembler) {
Return(elements); Return(elements);
BIND(&runtime); BIND(&runtime);
TailCallRuntime(Runtime::kGrowArrayElements, context, object, key); TailCallRuntime(Runtime::kGrowArrayElements, NoContextConstant(), object,
key);
} }
TF_BUILTIN(NewArgumentsElements, CodeStubAssembler) { TF_BUILTIN(NewArgumentsElements, CodeStubAssembler) {
Node* frame = Parameter(Descriptor::kFrame); TNode<IntPtrT> frame = UncheckedCast<IntPtrT>(Parameter(Descriptor::kFrame));
TNode<IntPtrT> length = SmiToIntPtr(Parameter(Descriptor::kLength)); TNode<IntPtrT> length = SmiToIntPtr(Parameter(Descriptor::kLength));
TNode<IntPtrT> mapped_count = TNode<IntPtrT> mapped_count =
SmiToIntPtr(Parameter(Descriptor::kMappedCount)); SmiToIntPtr(Parameter(Descriptor::kMappedCount));
...@@ -211,10 +211,10 @@ class RecordWriteCodeStubAssembler : public CodeStubAssembler { ...@@ -211,10 +211,10 @@ class RecordWriteCodeStubAssembler : public CodeStubAssembler {
explicit RecordWriteCodeStubAssembler(compiler::CodeAssemblerState* state) explicit RecordWriteCodeStubAssembler(compiler::CodeAssemblerState* state)
: CodeStubAssembler(state) {} : CodeStubAssembler(state) {}
Node* IsMarking() { TNode<BoolT> IsMarking() {
TNode<ExternalReference> is_marking_addr = ExternalConstant( TNode<ExternalReference> is_marking_addr = ExternalConstant(
ExternalReference::heap_is_marking_flag_address(this->isolate())); ExternalReference::heap_is_marking_flag_address(this->isolate()));
return Load(MachineType::Uint8(), is_marking_addr); return Word32NotEqual(Load<Uint8T>(is_marking_addr), Int32Constant(0));
} }
TNode<BoolT> IsPageFlagSet(TNode<IntPtrT> object, int mask) { TNode<BoolT> IsPageFlagSet(TNode<IntPtrT> object, int mask) {
...@@ -228,34 +228,34 @@ class RecordWriteCodeStubAssembler : public CodeStubAssembler { ...@@ -228,34 +228,34 @@ class RecordWriteCodeStubAssembler : public CodeStubAssembler {
TNode<BoolT> IsWhite(TNode<IntPtrT> object) { TNode<BoolT> IsWhite(TNode<IntPtrT> object) {
DCHECK_EQ(strcmp(Marking::kWhiteBitPattern, "00"), 0); DCHECK_EQ(strcmp(Marking::kWhiteBitPattern, "00"), 0);
Node* cell; TNode<IntPtrT> cell;
Node* mask; TNode<IntPtrT> mask;
GetMarkBit(object, &cell, &mask); GetMarkBit(object, &cell, &mask);
mask = TruncateIntPtrToInt32(mask); TNode<Int32T> mask32 = TruncateIntPtrToInt32(mask);
// Non-white has 1 for the first bit, so we only need to check for the first // Non-white has 1 for the first bit, so we only need to check for the first
// bit. // bit.
return Word32Equal(Word32And(Load(MachineType::Int32(), cell), mask), return Word32Equal(Word32And(Load<Int32T>(cell), mask32), Int32Constant(0));
Int32Constant(0));
} }
void GetMarkBit(TNode<IntPtrT> object, Node** cell, Node** mask) { void GetMarkBit(TNode<IntPtrT> object, TNode<IntPtrT>* cell,
TNode<IntPtrT>* mask) {
TNode<IntPtrT> page = PageFromAddress(object); TNode<IntPtrT> page = PageFromAddress(object);
Node* bitmap = Load(MachineType::Pointer(), page, TNode<IntPtrT> bitmap =
IntPtrConstant(MemoryChunk::kMarkBitmapOffset)); Load<IntPtrT>(page, IntPtrConstant(MemoryChunk::kMarkBitmapOffset));
{ {
// Temp variable to calculate cell offset in bitmap. // Temp variable to calculate cell offset in bitmap.
Node* r0; TNode<WordT> r0;
int shift = Bitmap::kBitsPerCellLog2 + kTaggedSizeLog2 - int shift = Bitmap::kBitsPerCellLog2 + kTaggedSizeLog2 -
Bitmap::kBytesPerCellLog2; Bitmap::kBytesPerCellLog2;
r0 = WordShr(object, IntPtrConstant(shift)); r0 = WordShr(object, IntPtrConstant(shift));
r0 = WordAnd(r0, IntPtrConstant((kPageAlignmentMask >> shift) & r0 = WordAnd(r0, IntPtrConstant((kPageAlignmentMask >> shift) &
~(Bitmap::kBytesPerCell - 1))); ~(Bitmap::kBytesPerCell - 1)));
*cell = IntPtrAdd(bitmap, r0); *cell = IntPtrAdd(bitmap, Signed(r0));
} }
{ {
// Temp variable to calculate bit offset in cell. // Temp variable to calculate bit offset in cell.
Node* r1; TNode<WordT> r1;
r1 = WordShr(object, IntPtrConstant(kTaggedSizeLog2)); r1 = WordShr(object, IntPtrConstant(kTaggedSizeLog2));
r1 = WordAnd(r1, IntPtrConstant((1 << Bitmap::kBitsPerCellLog2) - 1)); r1 = WordAnd(r1, IntPtrConstant((1 << Bitmap::kBitsPerCellLog2) - 1));
// It seems that LSB(e.g. cl) is automatically used, so no manual masking // It seems that LSB(e.g. cl) is automatically used, so no manual masking
...@@ -265,73 +265,78 @@ class RecordWriteCodeStubAssembler : public CodeStubAssembler { ...@@ -265,73 +265,78 @@ class RecordWriteCodeStubAssembler : public CodeStubAssembler {
} }
} }
Node* ShouldSkipFPRegs(SloppyTNode<Object> mode) { TNode<BoolT> ShouldSkipFPRegs(SloppyTNode<Smi> mode) {
return TaggedEqual(mode, SmiConstant(kDontSaveFPRegs)); return TaggedEqual(mode, SmiConstant(kDontSaveFPRegs));
} }
Node* ShouldEmitRememberSet(SloppyTNode<Object> remembered_set) { TNode<BoolT> ShouldEmitRememberSet(SloppyTNode<Smi> remembered_set) {
return TaggedEqual(remembered_set, SmiConstant(EMIT_REMEMBERED_SET)); return TaggedEqual(remembered_set, SmiConstant(EMIT_REMEMBERED_SET));
} }
template <typename Ret, typename Arg0, typename Arg1>
void CallCFunction2WithCallerSavedRegistersMode( void CallCFunction2WithCallerSavedRegistersMode(
MachineType return_type, MachineType arg0_type, MachineType arg1_type, TNode<ExternalReference> function, TNode<Arg0> arg0, TNode<Arg1> arg1,
Node* function, Node* arg0, Node* arg1, Node* mode, Label* next) { TNode<Smi> mode, Label* next) {
Label dont_save_fp(this), save_fp(this); Label dont_save_fp(this), save_fp(this);
Branch(ShouldSkipFPRegs(mode), &dont_save_fp, &save_fp); Branch(ShouldSkipFPRegs(mode), &dont_save_fp, &save_fp);
BIND(&dont_save_fp); BIND(&dont_save_fp);
{ {
CallCFunctionWithCallerSavedRegisters( CallCFunctionWithCallerSavedRegisters(
function, return_type, kDontSaveFPRegs, function, MachineTypeOf<Ret>::value, kDontSaveFPRegs,
std::make_pair(arg0_type, arg0), std::make_pair(arg1_type, arg1)); std::make_pair(MachineTypeOf<Arg0>::value, arg0),
std::make_pair(MachineTypeOf<Arg1>::value, arg1));
Goto(next); Goto(next);
} }
BIND(&save_fp); BIND(&save_fp);
{ {
CallCFunctionWithCallerSavedRegisters(function, return_type, kSaveFPRegs, CallCFunctionWithCallerSavedRegisters(
std::make_pair(arg0_type, arg0), function, MachineTypeOf<Ret>::value, kSaveFPRegs,
std::make_pair(arg1_type, arg1)); std::make_pair(MachineTypeOf<Arg0>::value, arg0),
std::make_pair(MachineTypeOf<Arg1>::value, arg1));
Goto(next); Goto(next);
} }
} }
template <typename Ret, typename Arg0, typename Arg1, typename Arg2>
void CallCFunction3WithCallerSavedRegistersMode( void CallCFunction3WithCallerSavedRegistersMode(
MachineType return_type, MachineType arg0_type, MachineType arg1_type, TNode<ExternalReference> function, TNode<Arg0> arg0, TNode<Arg1> arg1,
MachineType arg2_type, Node* function, Node* arg0, Node* arg1, Node* arg2, TNode<Arg2> arg2, TNode<Smi> mode, Label* next) {
Node* mode, Label* next) {
Label dont_save_fp(this), save_fp(this); Label dont_save_fp(this), save_fp(this);
Branch(ShouldSkipFPRegs(mode), &dont_save_fp, &save_fp); Branch(ShouldSkipFPRegs(mode), &dont_save_fp, &save_fp);
BIND(&dont_save_fp); BIND(&dont_save_fp);
{ {
CallCFunctionWithCallerSavedRegisters( CallCFunctionWithCallerSavedRegisters(
function, return_type, kDontSaveFPRegs, function, MachineTypeOf<Ret>::value, kDontSaveFPRegs,
std::make_pair(arg0_type, arg0), std::make_pair(arg1_type, arg1), std::make_pair(MachineTypeOf<Arg0>::value, arg0),
std::make_pair(arg2_type, arg2)); std::make_pair(MachineTypeOf<Arg1>::value, arg1),
std::make_pair(MachineTypeOf<Arg2>::value, arg2));
Goto(next); Goto(next);
} }
BIND(&save_fp); BIND(&save_fp);
{ {
CallCFunctionWithCallerSavedRegisters( CallCFunctionWithCallerSavedRegisters(
function, return_type, kSaveFPRegs, std::make_pair(arg0_type, arg0), function, MachineTypeOf<Ret>::value, kSaveFPRegs,
std::make_pair(arg1_type, arg1), std::make_pair(arg2_type, arg2)); std::make_pair(MachineTypeOf<Arg0>::value, arg0),
std::make_pair(MachineTypeOf<Arg1>::value, arg1),
std::make_pair(MachineTypeOf<Arg2>::value, arg2));
Goto(next); Goto(next);
} }
} }
void InsertIntoRememberedSetAndGotoSlow(TNode<IntPtrT> object, void InsertIntoRememberedSetAndGotoSlow(TNode<IntPtrT> object,
TNode<IntPtrT> slot, Node* mode, TNode<IntPtrT> slot, TNode<Smi> mode,
Label* next) { Label* next) {
TNode<IntPtrT> page = PageFromAddress(object); TNode<IntPtrT> page = PageFromAddress(object);
TNode<ExternalReference> function = TNode<ExternalReference> function =
ExternalConstant(ExternalReference::insert_remembered_set_function()); ExternalConstant(ExternalReference::insert_remembered_set_function());
CallCFunction2WithCallerSavedRegistersMode( CallCFunction2WithCallerSavedRegistersMode<Int32T, IntPtrT, IntPtrT>(
MachineType::Int32(), MachineType::Pointer(), MachineType::Pointer(),
function, page, slot, mode, next); function, page, slot, mode, next);
} }
void InsertIntoRememberedSetAndGoto(TNode<IntPtrT> object, void InsertIntoRememberedSetAndGoto(TNode<IntPtrT> object,
TNode<IntPtrT> slot, Node* mode, TNode<IntPtrT> slot, TNode<Smi> mode,
Label* next) { Label* next) {
Label slow_path(this); Label slow_path(this);
TNode<IntPtrT> page = PageFromAddress(object); TNode<IntPtrT> page = PageFromAddress(object);
...@@ -401,7 +406,8 @@ TF_BUILTIN(RecordWrite, RecordWriteCodeStubAssembler) { ...@@ -401,7 +406,8 @@ TF_BUILTIN(RecordWrite, RecordWriteCodeStubAssembler) {
Label incremental_wb(this); Label incremental_wb(this);
Label exit(this); Label exit(this);
Node* remembered_set = Parameter(Descriptor::kRememberedSet); TNode<Smi> remembered_set =
UncheckedCast<Smi>(Parameter(Descriptor::kRememberedSet));
Branch(ShouldEmitRememberSet(remembered_set), &generational_wb, Branch(ShouldEmitRememberSet(remembered_set), &generational_wb,
&incremental_wb); &incremental_wb);
...@@ -440,7 +446,7 @@ TF_BUILTIN(RecordWrite, RecordWriteCodeStubAssembler) { ...@@ -440,7 +446,7 @@ TF_BUILTIN(RecordWrite, RecordWriteCodeStubAssembler) {
BIND(&store_buffer_exit); BIND(&store_buffer_exit);
{ {
Node* fp_mode = Parameter(Descriptor::kFPMode); TNode<Smi> fp_mode = UncheckedCast<Smi>(Parameter(Descriptor::kFPMode));
TNode<IntPtrT> object = TNode<IntPtrT> object =
BitcastTaggedToWord(Parameter(Descriptor::kObject)); BitcastTaggedToWord(Parameter(Descriptor::kObject));
InsertIntoRememberedSetAndGoto(object, slot, fp_mode, &exit); InsertIntoRememberedSetAndGoto(object, slot, fp_mode, &exit);
...@@ -448,7 +454,7 @@ TF_BUILTIN(RecordWrite, RecordWriteCodeStubAssembler) { ...@@ -448,7 +454,7 @@ TF_BUILTIN(RecordWrite, RecordWriteCodeStubAssembler) {
BIND(&store_buffer_incremental_wb); BIND(&store_buffer_incremental_wb);
{ {
Node* fp_mode = Parameter(Descriptor::kFPMode); TNode<Smi> fp_mode = UncheckedCast<Smi>(Parameter(Descriptor::kFPMode));
TNode<IntPtrT> object = TNode<IntPtrT> object =
BitcastTaggedToWord(Parameter(Descriptor::kObject)); BitcastTaggedToWord(Parameter(Descriptor::kObject));
InsertIntoRememberedSetAndGoto(object, slot, fp_mode, &incremental_wb); InsertIntoRememberedSetAndGoto(object, slot, fp_mode, &incremental_wb);
...@@ -483,13 +489,12 @@ TF_BUILTIN(RecordWrite, RecordWriteCodeStubAssembler) { ...@@ -483,13 +489,12 @@ TF_BUILTIN(RecordWrite, RecordWriteCodeStubAssembler) {
ExternalReference::incremental_marking_record_write_function()); ExternalReference::incremental_marking_record_write_function());
TNode<ExternalReference> isolate_constant = TNode<ExternalReference> isolate_constant =
ExternalConstant(ExternalReference::isolate_address(isolate())); ExternalConstant(ExternalReference::isolate_address(isolate()));
Node* fp_mode = Parameter(Descriptor::kFPMode); TNode<Smi> fp_mode = UncheckedCast<Smi>(Parameter(Descriptor::kFPMode));
TNode<IntPtrT> object = TNode<IntPtrT> object =
BitcastTaggedToWord(Parameter(Descriptor::kObject)); BitcastTaggedToWord(Parameter(Descriptor::kObject));
CallCFunction3WithCallerSavedRegistersMode( CallCFunction3WithCallerSavedRegistersMode<Int32T, IntPtrT, IntPtrT,
MachineType::Int32(), MachineType::Pointer(), MachineType::Pointer(), ExternalReference>(
MachineType::Pointer(), function, object, slot, isolate_constant, function, object, slot, isolate_constant, fp_mode, &exit);
fp_mode, &exit);
} }
} }
...@@ -505,13 +510,13 @@ TF_BUILTIN(EphemeronKeyBarrier, RecordWriteCodeStubAssembler) { ...@@ -505,13 +510,13 @@ TF_BUILTIN(EphemeronKeyBarrier, RecordWriteCodeStubAssembler) {
ExternalReference::ephemeron_key_write_barrier_function()); ExternalReference::ephemeron_key_write_barrier_function());
TNode<ExternalReference> isolate_constant = TNode<ExternalReference> isolate_constant =
ExternalConstant(ExternalReference::isolate_address(isolate())); ExternalConstant(ExternalReference::isolate_address(isolate()));
Node* address = Parameter(Descriptor::kSlotAddress); TNode<IntPtrT> address =
UncheckedCast<IntPtrT>(Parameter(Descriptor::kSlotAddress));
TNode<IntPtrT> object = BitcastTaggedToWord(Parameter(Descriptor::kObject)); TNode<IntPtrT> object = BitcastTaggedToWord(Parameter(Descriptor::kObject));
Node* fp_mode = Parameter(Descriptor::kFPMode); TNode<Smi> fp_mode = UncheckedCast<Smi>(Parameter(Descriptor::kFPMode));
CallCFunction3WithCallerSavedRegistersMode( CallCFunction3WithCallerSavedRegistersMode<Int32T, IntPtrT, IntPtrT,
MachineType::Int32(), MachineType::Pointer(), MachineType::Pointer(), ExternalReference>(
MachineType::Pointer(), function, object, address, isolate_constant, function, object, address, isolate_constant, fp_mode, &exit);
fp_mode, &exit);
BIND(&exit); BIND(&exit);
IncrementCounter(isolate()->counters()->write_barriers(), 1); IncrementCounter(isolate()->counters()->write_barriers(), 1);
...@@ -776,11 +781,9 @@ TF_BUILTIN(ForInEnumerate, CodeStubAssembler) { ...@@ -776,11 +781,9 @@ TF_BUILTIN(ForInEnumerate, CodeStubAssembler) {
} }
TF_BUILTIN(ForInFilter, CodeStubAssembler) { TF_BUILTIN(ForInFilter, CodeStubAssembler) {
Node* key = Parameter(Descriptor::kKey); TNode<String> key = CAST(Parameter(Descriptor::kKey));
Node* object = Parameter(Descriptor::kObject); TNode<HeapObject> object = CAST(Parameter(Descriptor::kObject));
Node* context = Parameter(Descriptor::kContext); TNode<Context> context = CAST(Parameter(Descriptor::kContext));
CSA_ASSERT(this, IsString(key));
Label if_true(this), if_false(this); Label if_true(this), if_false(this);
TNode<Oddball> result = HasProperty(context, object, key, kForInHasProperty); TNode<Oddball> result = HasProperty(context, object, key, kForInHasProperty);
...@@ -794,8 +797,8 @@ TF_BUILTIN(ForInFilter, CodeStubAssembler) { ...@@ -794,8 +797,8 @@ TF_BUILTIN(ForInFilter, CodeStubAssembler) {
} }
TF_BUILTIN(SameValue, CodeStubAssembler) { TF_BUILTIN(SameValue, CodeStubAssembler) {
Node* lhs = Parameter(Descriptor::kLeft); TNode<Object> lhs = CAST(Parameter(Descriptor::kLeft));
Node* rhs = Parameter(Descriptor::kRight); TNode<Object> rhs = CAST(Parameter(Descriptor::kRight));
Label if_true(this), if_false(this); Label if_true(this), if_false(this);
BranchIfSameValue(lhs, rhs, &if_true, &if_false); BranchIfSameValue(lhs, rhs, &if_true, &if_false);
...@@ -808,8 +811,8 @@ TF_BUILTIN(SameValue, CodeStubAssembler) { ...@@ -808,8 +811,8 @@ TF_BUILTIN(SameValue, CodeStubAssembler) {
} }
TF_BUILTIN(SameValueNumbersOnly, CodeStubAssembler) { TF_BUILTIN(SameValueNumbersOnly, CodeStubAssembler) {
Node* lhs = Parameter(Descriptor::kLeft); TNode<Object> lhs = CAST(Parameter(Descriptor::kLeft));
Node* rhs = Parameter(Descriptor::kRight); TNode<Object> rhs = CAST(Parameter(Descriptor::kRight));
Label if_true(this), if_false(this); Label if_true(this), if_false(this);
BranchIfSameValue(lhs, rhs, &if_true, &if_false, SameValueMode::kNumbersOnly); BranchIfSameValue(lhs, rhs, &if_true, &if_false, SameValueMode::kNumbersOnly);
...@@ -984,19 +987,19 @@ void Builtins::Generate_MemMove(MacroAssembler* masm) { ...@@ -984,19 +987,19 @@ void Builtins::Generate_MemMove(MacroAssembler* masm) {
// ES6 [[Get]] operation. // ES6 [[Get]] operation.
TF_BUILTIN(GetProperty, CodeStubAssembler) { TF_BUILTIN(GetProperty, CodeStubAssembler) {
Node* object = Parameter(Descriptor::kObject); TNode<Object> object = CAST(Parameter(Descriptor::kObject));
Node* key = Parameter(Descriptor::kKey); TNode<Object> key = CAST(Parameter(Descriptor::kKey));
Node* context = Parameter(Descriptor::kContext); TNode<Context> context = CAST(Parameter(Descriptor::kContext));
// TODO(duongn): consider tailcalling to GetPropertyWithReceiver(object, // TODO(duongn): consider tailcalling to GetPropertyWithReceiver(object,
// object, key, OnNonExistent::kReturnUndefined). // object, key, OnNonExistent::kReturnUndefined).
Label if_notfound(this), if_proxy(this, Label::kDeferred), Label if_notfound(this), if_proxy(this, Label::kDeferred),
if_slow(this, Label::kDeferred); if_slow(this, Label::kDeferred);
CodeStubAssembler::LookupInHolder lookup_property_in_holder = CodeStubAssembler::LookupPropertyInHolder lookup_property_in_holder =
[=](Node* receiver, Node* holder, Node* holder_map, [=](TNode<HeapObject> receiver, TNode<HeapObject> holder,
Node* holder_instance_type, Node* unique_name, Label* next_holder, TNode<Map> holder_map, TNode<Int32T> holder_instance_type,
Label* if_bailout) { TNode<Name> unique_name, Label* next_holder, Label* if_bailout) {
VARIABLE(var_value, MachineRepresentation::kTagged); TVARIABLE(Object, var_value);
Label if_found(this); Label if_found(this);
TryGetOwnProperty(context, receiver, holder, holder_map, TryGetOwnProperty(context, receiver, holder, holder_map,
holder_instance_type, unique_name, &if_found, holder_instance_type, unique_name, &if_found,
...@@ -1005,10 +1008,10 @@ TF_BUILTIN(GetProperty, CodeStubAssembler) { ...@@ -1005,10 +1008,10 @@ TF_BUILTIN(GetProperty, CodeStubAssembler) {
Return(var_value.value()); Return(var_value.value());
}; };
CodeStubAssembler::LookupInHolder lookup_element_in_holder = CodeStubAssembler::LookupElementInHolder lookup_element_in_holder =
[=](Node* receiver, Node* holder, Node* holder_map, [=](TNode<HeapObject> receiver, TNode<HeapObject> holder,
Node* holder_instance_type, Node* index, Label* next_holder, TNode<Map> holder_map, TNode<Int32T> holder_instance_type,
Label* if_bailout) { TNode<IntPtrT> index, Label* next_holder, Label* if_bailout) {
// Not supported yet. // Not supported yet.
Use(next_holder); Use(next_holder);
Goto(if_bailout); Goto(if_bailout);
...@@ -1039,19 +1042,19 @@ TF_BUILTIN(GetProperty, CodeStubAssembler) { ...@@ -1039,19 +1042,19 @@ TF_BUILTIN(GetProperty, CodeStubAssembler) {
// ES6 [[Get]] operation with Receiver. // ES6 [[Get]] operation with Receiver.
TF_BUILTIN(GetPropertyWithReceiver, CodeStubAssembler) { TF_BUILTIN(GetPropertyWithReceiver, CodeStubAssembler) {
Node* object = Parameter(Descriptor::kObject); TNode<Object> object = CAST(Parameter(Descriptor::kObject));
Node* key = Parameter(Descriptor::kKey); TNode<Object> key = CAST(Parameter(Descriptor::kKey));
Node* context = Parameter(Descriptor::kContext); TNode<Context> context = CAST(Parameter(Descriptor::kContext));
Node* receiver = Parameter(Descriptor::kReceiver); TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver));
TNode<Object> on_non_existent = CAST(Parameter(Descriptor::kOnNonExistent)); TNode<Object> on_non_existent = CAST(Parameter(Descriptor::kOnNonExistent));
Label if_notfound(this), if_proxy(this, Label::kDeferred), Label if_notfound(this), if_proxy(this, Label::kDeferred),
if_slow(this, Label::kDeferred); if_slow(this, Label::kDeferred);
CodeStubAssembler::LookupInHolder lookup_property_in_holder = CodeStubAssembler::LookupPropertyInHolder lookup_property_in_holder =
[=](Node* receiver, Node* holder, Node* holder_map, [=](TNode<HeapObject> receiver, TNode<HeapObject> holder,
Node* holder_instance_type, Node* unique_name, Label* next_holder, TNode<Map> holder_map, TNode<Int32T> holder_instance_type,
Label* if_bailout) { TNode<Name> unique_name, Label* next_holder, Label* if_bailout) {
VARIABLE(var_value, MachineRepresentation::kTagged); TVARIABLE(Object, var_value);
Label if_found(this); Label if_found(this);
TryGetOwnProperty(context, receiver, holder, holder_map, TryGetOwnProperty(context, receiver, holder, holder_map,
holder_instance_type, unique_name, &if_found, holder_instance_type, unique_name, &if_found,
...@@ -1060,10 +1063,10 @@ TF_BUILTIN(GetPropertyWithReceiver, CodeStubAssembler) { ...@@ -1060,10 +1063,10 @@ TF_BUILTIN(GetPropertyWithReceiver, CodeStubAssembler) {
Return(var_value.value()); Return(var_value.value());
}; };
CodeStubAssembler::LookupInHolder lookup_element_in_holder = CodeStubAssembler::LookupElementInHolder lookup_element_in_holder =
[=](Node* receiver, Node* holder, Node* holder_map, [=](TNode<HeapObject> receiver, TNode<HeapObject> holder,
Node* holder_instance_type, Node* index, Label* next_holder, TNode<Map> holder_map, TNode<Int32T> holder_instance_type,
Label* if_bailout) { TNode<IntPtrT> index, Label* next_holder, Label* if_bailout) {
// Not supported yet. // Not supported yet.
Use(next_holder); Use(next_holder);
Goto(if_bailout); Goto(if_bailout);
......
...@@ -262,10 +262,10 @@ TNode<JSArray> ObjectEntriesValuesBuiltinsAssembler::FastGetOwnValuesOrEntries( ...@@ -262,10 +262,10 @@ TNode<JSArray> ObjectEntriesValuesBuiltinsAssembler::FastGetOwnValuesOrEntries(
TVARIABLE(IntPtrT, var_result_index, IntPtrConstant(0)); TVARIABLE(IntPtrT, var_result_index, IntPtrConstant(0));
TVARIABLE(IntPtrT, var_descriptor_number, IntPtrConstant(0)); TVARIABLE(IntPtrT, var_descriptor_number, IntPtrConstant(0));
VariableList vars({&var_descriptor_number, &var_result_index}, zone());
// Let desc be ? O.[[GetOwnProperty]](key). // Let desc be ? O.[[GetOwnProperty]](key).
TNode<DescriptorArray> descriptors = LoadMapDescriptors(map); TNode<DescriptorArray> descriptors = LoadMapDescriptors(map);
Label loop(this, vars), after_loop(this), next_descriptor(this); Label loop(this, {&var_descriptor_number, &var_result_index}),
after_loop(this), next_descriptor(this);
Branch(IntPtrEqual(var_descriptor_number.value(), object_enum_length), Branch(IntPtrEqual(var_descriptor_number.value(), object_enum_length),
&after_loop, &loop); &after_loop, &loop);
......
...@@ -9298,13 +9298,13 @@ void CodeStubAssembler::BranchIfMaybeSpecialIndex(TNode<String> name_string, ...@@ -9298,13 +9298,13 @@ void CodeStubAssembler::BranchIfMaybeSpecialIndex(TNode<String> name_string,
} }
void CodeStubAssembler::TryPrototypeChainLookup( void CodeStubAssembler::TryPrototypeChainLookup(
Node* receiver, Node* object, Node* key, TNode<Object> receiver, TNode<Object> object_arg, TNode<Object> key,
const LookupInHolder& lookup_property_in_holder, const LookupPropertyInHolder& lookup_property_in_holder,
const LookupInHolder& lookup_element_in_holder, Label* if_end, const LookupElementInHolder& lookup_element_in_holder, Label* if_end,
Label* if_bailout, Label* if_proxy) { Label* if_bailout, Label* if_proxy) {
// Ensure receiver is JSReceiver, otherwise bailout. // Ensure receiver is JSReceiver, otherwise bailout.
GotoIf(TaggedIsSmi(receiver), if_bailout); GotoIf(TaggedIsSmi(receiver), if_bailout);
CSA_ASSERT(this, TaggedIsNotSmi(object)); TNode<HeapObject> object = CAST(object_arg);
TNode<Map> map = LoadMap(object); TNode<Map> map = LoadMap(object);
TNode<Uint16T> instance_type = LoadMapInstanceType(map); TNode<Uint16T> instance_type = LoadMapInstanceType(map);
...@@ -9328,7 +9328,7 @@ void CodeStubAssembler::TryPrototypeChainLookup( ...@@ -9328,7 +9328,7 @@ void CodeStubAssembler::TryPrototypeChainLookup(
BIND(&if_iskeyunique); BIND(&if_iskeyunique);
{ {
TVARIABLE(HeapObject, var_holder, CAST(object)); TVARIABLE(HeapObject, var_holder, object);
TVARIABLE(Map, var_holder_map, map); TVARIABLE(Map, var_holder_map, map);
TVARIABLE(Int32T, var_holder_instance_type, instance_type); TVARIABLE(Int32T, var_holder_instance_type, instance_type);
...@@ -9340,7 +9340,7 @@ void CodeStubAssembler::TryPrototypeChainLookup( ...@@ -9340,7 +9340,7 @@ void CodeStubAssembler::TryPrototypeChainLookup(
TNode<Int32T> holder_instance_type = var_holder_instance_type.value(); TNode<Int32T> holder_instance_type = var_holder_instance_type.value();
Label next_proto(this), check_integer_indexed_exotic(this); Label next_proto(this), check_integer_indexed_exotic(this);
lookup_property_in_holder(receiver, var_holder.value(), holder_map, lookup_property_in_holder(CAST(receiver), var_holder.value(), holder_map,
holder_instance_type, var_unique.value(), holder_instance_type, var_unique.value(),
&check_integer_indexed_exotic, if_bailout); &check_integer_indexed_exotic, if_bailout);
...@@ -9371,7 +9371,7 @@ void CodeStubAssembler::TryPrototypeChainLookup( ...@@ -9371,7 +9371,7 @@ void CodeStubAssembler::TryPrototypeChainLookup(
} }
BIND(&if_keyisindex); BIND(&if_keyisindex);
{ {
TVARIABLE(HeapObject, var_holder, CAST(object)); TVARIABLE(HeapObject, var_holder, object);
TVARIABLE(Map, var_holder_map, map); TVARIABLE(Map, var_holder_map, map);
TVARIABLE(Int32T, var_holder_instance_type, instance_type); TVARIABLE(Int32T, var_holder_instance_type, instance_type);
...@@ -9380,7 +9380,7 @@ void CodeStubAssembler::TryPrototypeChainLookup( ...@@ -9380,7 +9380,7 @@ void CodeStubAssembler::TryPrototypeChainLookup(
BIND(&loop); BIND(&loop);
{ {
Label next_proto(this); Label next_proto(this);
lookup_element_in_holder(receiver, var_holder.value(), lookup_element_in_holder(CAST(receiver), var_holder.value(),
var_holder_map.value(), var_holder_map.value(),
var_holder_instance_type.value(), var_holder_instance_type.value(),
var_index.value(), &next_proto, if_bailout); var_index.value(), &next_proto, if_bailout);
...@@ -12135,19 +12135,20 @@ TNode<Oddball> CodeStubAssembler::HasProperty(SloppyTNode<Context> context, ...@@ -12135,19 +12135,20 @@ TNode<Oddball> CodeStubAssembler::HasProperty(SloppyTNode<Context> context,
Label call_runtime(this, Label::kDeferred), return_true(this), Label call_runtime(this, Label::kDeferred), return_true(this),
return_false(this), end(this), if_proxy(this, Label::kDeferred); return_false(this), end(this), if_proxy(this, Label::kDeferred);
CodeStubAssembler::LookupInHolder lookup_property_in_holder = CodeStubAssembler::LookupPropertyInHolder lookup_property_in_holder =
[this, &return_true](Node* receiver, Node* holder, Node* holder_map, [this, &return_true](
Node* holder_instance_type, Node* unique_name, TNode<HeapObject> receiver, TNode<HeapObject> holder,
Label* next_holder, Label* if_bailout) { TNode<Map> holder_map, TNode<Int32T> holder_instance_type,
TNode<Name> unique_name, Label* next_holder, Label* if_bailout) {
TryHasOwnProperty(holder, holder_map, holder_instance_type, unique_name, TryHasOwnProperty(holder, holder_map, holder_instance_type, unique_name,
&return_true, next_holder, if_bailout); &return_true, next_holder, if_bailout);
}; };
CodeStubAssembler::LookupInHolder lookup_element_in_holder = CodeStubAssembler::LookupElementInHolder lookup_element_in_holder =
[this, &return_true, &return_false]( [this, &return_true, &return_false](
Node* receiver, Node* holder, Node* holder_map, TNode<HeapObject> receiver, TNode<HeapObject> holder,
Node* holder_instance_type, Node* index, Label* next_holder, TNode<Map> holder_map, TNode<Int32T> holder_instance_type,
Label* if_bailout) { TNode<IntPtrT> index, Label* next_holder, Label* if_bailout) {
TryLookupElement(holder, holder_map, holder_instance_type, index, TryLookupElement(holder, holder_map, holder_instance_type, index,
&return_true, &return_false, next_holder, if_bailout); &return_true, &return_false, next_holder, if_bailout);
}; };
......
...@@ -3112,13 +3112,6 @@ class V8_EXPORT_PRIVATE CodeStubAssembler ...@@ -3112,13 +3112,6 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
Label* if_absent, Label* if_not_found, Label* if_absent, Label* if_not_found,
Label* if_bailout); Label* if_bailout);
// This is a type of a lookup in holder generator function. In case of a
// property lookup the {key} is guaranteed to be an unique name and in case of
// element lookup the key is an Int32 index.
using LookupInHolder = std::function<void(
Node* receiver, Node* holder, Node* map, Node* instance_type, Node* key,
Label* next_holder, Label* if_bailout)>;
// For integer indexed exotic cases, check if the given string cannot be a // For integer indexed exotic cases, check if the given string cannot be a
// special index. If we are not sure that the given string is not a special // special index. If we are not sure that the given string is not a special
// index with a simple check, return False. Note that "False" return value // index with a simple check, return False. Note that "False" return value
...@@ -3128,6 +3121,20 @@ class V8_EXPORT_PRIVATE CodeStubAssembler ...@@ -3128,6 +3121,20 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
Label* if_maybe_special_index, Label* if_maybe_special_index,
Label* if_not_special_index); Label* if_not_special_index);
// This is a type of a lookup property in holder generator function. The {key}
// is guaranteed to be an unique name.
using LookupPropertyInHolder = std::function<void(
TNode<HeapObject> receiver, TNode<HeapObject> holder, TNode<Map> map,
TNode<Int32T> instance_type, TNode<Name> key, Label* next_holder,
Label* if_bailout)>;
// This is a type of a lookup element in holder generator function. The {key}
// is an Int32 index.
using LookupElementInHolder = std::function<void(
TNode<HeapObject> receiver, TNode<HeapObject> holder, TNode<Map> map,
TNode<Int32T> instance_type, TNode<IntPtrT> key, Label* next_holder,
Label* if_bailout)>;
// Generic property prototype chain lookup generator. // Generic property prototype chain lookup generator.
// For properties it generates lookup using given {lookup_property_in_holder} // For properties it generates lookup using given {lookup_property_in_holder}
// and for elements it uses {lookup_element_in_holder}. // and for elements it uses {lookup_element_in_holder}.
...@@ -3135,11 +3142,11 @@ class V8_EXPORT_PRIVATE CodeStubAssembler ...@@ -3135,11 +3142,11 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
// If it can't handle the case {receiver}/{key} case then the control goes // If it can't handle the case {receiver}/{key} case then the control goes
// to {if_bailout}. // to {if_bailout}.
// If {if_proxy} is nullptr, proxies go to if_bailout. // If {if_proxy} is nullptr, proxies go to if_bailout.
void TryPrototypeChainLookup(Node* receiver, Node* object, Node* key, void TryPrototypeChainLookup(
const LookupInHolder& lookup_property_in_holder, TNode<Object> receiver, TNode<Object> object, TNode<Object> key,
const LookupInHolder& lookup_element_in_holder, const LookupPropertyInHolder& lookup_property_in_holder,
Label* if_end, Label* if_bailout, const LookupElementInHolder& lookup_element_in_holder, Label* if_end,
Label* if_proxy); Label* if_bailout, Label* if_proxy);
// Instanceof helpers. // Instanceof helpers.
// Returns true if {object} has {prototype} somewhere in it's prototype // Returns true if {object} has {prototype} somewhere in it's prototype
......
// Copyright 2019 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.
#include "src/codegen/tnode.h"
namespace v8 {
namespace internal {
constexpr MachineType MachineTypeOf<ExternalReference>::value;
} // namespace internal
} // namespace v8
...@@ -137,6 +137,10 @@ struct MachineTypeOf<HeapObjectSubtype, ...@@ -137,6 +137,10 @@ struct MachineTypeOf<HeapObjectSubtype,
HeapObject, HeapObjectSubtype>::value>::type> { HeapObject, HeapObjectSubtype>::value>::type> {
static constexpr MachineType value = MachineType::TaggedPointer(); static constexpr MachineType value = MachineType::TaggedPointer();
}; };
template <>
struct MachineTypeOf<ExternalReference> {
static constexpr MachineType value = MachineType::Pointer();
};
template <class HeapObjectSubtype> template <class HeapObjectSubtype>
constexpr MachineType MachineTypeOf< constexpr MachineType MachineTypeOf<
......
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