Commit c522c6ba authored by ishell's avatar ishell Committed by Commit bot

[turbofan] Further adapting machine graph verifier to code stubs.

All accessor IC stubs now pass the verification.

BUG=

Review-Url: https://codereview.chromium.org/2556123002
Cr-Commit-Position: refs/heads/master@{#41585}
parent 044b2d1b
......@@ -473,6 +473,10 @@ Node* CodeStubAssembler::SmiLessThanOrEqual(Node* a, Node* b) {
return IntPtrLessThanOrEqual(BitcastTaggedToWord(a), BitcastTaggedToWord(b));
}
Node* CodeStubAssembler::SmiGreaterThan(Node* a, Node* b) {
return IntPtrGreaterThan(BitcastTaggedToWord(a), BitcastTaggedToWord(b));
}
Node* CodeStubAssembler::SmiMax(Node* a, Node* b) {
return SelectTaggedConstant(SmiLessThan(a, b), b, a);
}
......@@ -2057,10 +2061,9 @@ Node* CodeStubAssembler::AllocateJSArray(ElementsKind kind, Node* array_map,
TagParameter(capacity, capacity_mode));
// Fill in the elements with holes.
FillFixedArrayWithValue(
kind, elements, capacity_mode == SMI_PARAMETERS ? SmiConstant(Smi::kZero)
: IntPtrConstant(0),
capacity, Heap::kTheHoleValueRootIndex, capacity_mode);
FillFixedArrayWithValue(kind, elements, IntPtrOrSmiConstant(0, capacity_mode),
capacity, Heap::kTheHoleValueRootIndex,
capacity_mode);
return array;
}
......@@ -2069,8 +2072,8 @@ Node* CodeStubAssembler::AllocateFixedArray(ElementsKind kind,
Node* capacity_node,
ParameterMode mode,
AllocationFlags flags) {
CSA_ASSERT(this,
IntPtrGreaterThan(capacity_node, IntPtrOrSmiConstant(0, mode)));
CSA_ASSERT(this, IntPtrOrSmiGreaterThan(capacity_node,
IntPtrOrSmiConstant(0, mode), mode));
Node* total_size = GetFixedArrayAllocationSize(capacity_node, kind, mode);
// Allocate both array and elements object, and initialize the JSArray.
......@@ -5504,7 +5507,7 @@ void CodeStubAssembler::ExtendPropertiesBackingStore(Node* object) {
length = UntagParameter(length, mode);
Node* delta = IntPtrOrSmiConstant(JSObject::kFieldsAdded, mode);
Node* new_capacity = IntPtrAdd(length, delta);
Node* new_capacity = IntPtrOrSmiAdd(length, delta, mode);
// Grow properties array.
ElementsKind kind = FAST_ELEMENTS;
......@@ -5512,9 +5515,12 @@ void CodeStubAssembler::ExtendPropertiesBackingStore(Node* object) {
FixedArrayBase::GetMaxLengthForNewSpaceAllocation(kind));
// The size of a new properties backing store is guaranteed to be small
// enough that the new backing store will be allocated in new space.
CSA_ASSERT(this, UintPtrLessThan(new_capacity,
IntPtrConstant(kMaxNumberOfDescriptors +
JSObject::kFieldsAdded)));
CSA_ASSERT(this,
UintPtrOrSmiLessThan(
new_capacity,
IntPtrOrSmiConstant(
kMaxNumberOfDescriptors + JSObject::kFieldsAdded, mode),
mode));
Node* new_properties = AllocateFixedArray(kind, new_capacity, mode);
......
......@@ -94,6 +94,28 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
return value;
}
#define PARAMETER_BINARY_OPERATION(OpName, IntPtrOpName, SmiOpName, \
Int32OpName) \
Node* OpName(Node* value1, Node* value2, ParameterMode mode) { \
if (mode == SMI_PARAMETERS) { \
return SmiOpName(value1, value2); \
} else if (mode == INTPTR_PARAMETERS) { \
return IntPtrOpName(value1, value2); \
} else { \
DCHECK_EQ(INTEGER_PARAMETERS, mode); \
return Int32OpName(value1, value2); \
} \
}
PARAMETER_BINARY_OPERATION(IntPtrOrSmiAdd, IntPtrAdd, SmiAdd, Int32Add)
PARAMETER_BINARY_OPERATION(IntPtrOrSmiLessThan, IntPtrLessThan, SmiLessThan,
Int32LessThan)
PARAMETER_BINARY_OPERATION(IntPtrOrSmiGreaterThan, IntPtrGreaterThan,
SmiGreaterThan, Int32GreaterThan)
PARAMETER_BINARY_OPERATION(UintPtrOrSmiLessThan, UintPtrLessThan, SmiBelow,
Uint32LessThan)
#undef PARAMETER_BINARY_OPERATION
Node* NoContextConstant();
#define HEAP_CONSTANT_ACCESSOR(rootName, name) Node* name##Constant();
HEAP_CONSTANT_LIST(HEAP_CONSTANT_ACCESSOR)
......@@ -142,6 +164,7 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
Node* SmiBelow(Node* a, Node* b);
Node* SmiLessThan(Node* a, Node* b);
Node* SmiLessThanOrEqual(Node* a, Node* b);
Node* SmiGreaterThan(Node* a, Node* b);
Node* SmiMax(Node* a, Node* b);
Node* SmiMin(Node* a, Node* b);
// Computes a % b for Smi inputs a and b; result is not necessarily a Smi.
......
......@@ -1652,6 +1652,12 @@ Handle<Code> Pipeline::GenerateCodeForCodeStub(Isolate* isolate,
DCHECK_NOT_NULL(data.schedule());
if (FLAG_trace_turbo) {
{
CodeTracer::Scope tracing_scope(isolate->GetCodeTracer());
OFStream os(tracing_scope.file());
os << "---------------------------------------------------\n"
<< "Begin compiling " << debug_name << " using Turbofan" << std::endl;
}
{
TurboJsonFile json_of(&info, std::ios_base::trunc);
json_of << "{\"function\":\"" << info.GetDebugName().get()
......
......@@ -1958,8 +1958,16 @@ TEST(CodeStubAssemblerGraphsCorrectness) {
// Recompile some stubs here.
Recompile<LoadGlobalICStub>(isolate, LoadGlobalICState(NOT_INSIDE_TYPEOF));
Recompile<LoadGlobalICTrampolineStub>(isolate,
LoadGlobalICState(NOT_INSIDE_TYPEOF));
Recompile<LoadICStub>(isolate);
Recompile<LoadICTrampolineStub>(isolate);
Recompile<KeyedLoadICTFStub>(isolate);
Recompile<KeyedLoadICTrampolineTFStub>(isolate);
Recompile<StoreICStub>(isolate, StoreICState(STRICT));
Recompile<StoreICTrampolineStub>(isolate, StoreICState(STRICT));
Recompile<KeyedStoreICTFStub>(isolate, StoreICState(STRICT));
Recompile<KeyedStoreICTrampolineTFStub>(isolate, StoreICState(STRICT));
}
v8_isolate->Dispose();
}
......
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