Commit 072ea0c8 authored by cbruni's avatar cbruni Committed by Commit bot

[tests] Change CodeStubAssemblerTester code type to BUILTIN

Drive-by-fix 1: be more precise in machine representations for
AllocateNameDictionary to make --turbo_verify_machine_graph happy.

Drive-by-fix 2: Improve graph verifier output by printing input
representation.

BUG=

Review-Url: https://codereview.chromium.org/2475913002
Cr-Commit-Position: refs/heads/master@{#40797}
parent 7344f4f0
...@@ -141,7 +141,8 @@ Node* CodeStubAssembler::WordIsPowerOfTwo(Node* value) { ...@@ -141,7 +141,8 @@ Node* CodeStubAssembler::WordIsPowerOfTwo(Node* value) {
// value && !(value & (value - 1)) // value && !(value & (value - 1))
return WordEqual( return WordEqual(
Select(WordEqual(value, IntPtrConstant(0)), IntPtrConstant(1), Select(WordEqual(value, IntPtrConstant(0)), IntPtrConstant(1),
WordAnd(value, IntPtrSub(value, IntPtrConstant(1)))), WordAnd(value, IntPtrSub(value, IntPtrConstant(1))),
MachineType::PointerRepresentation()),
IntPtrConstant(0)); IntPtrConstant(0));
} }
...@@ -1708,6 +1709,7 @@ Node* CodeStubAssembler::AllocateNameDictionary(Node* at_least_space_for) { ...@@ -1708,6 +1709,7 @@ Node* CodeStubAssembler::AllocateNameDictionary(Node* at_least_space_for) {
SKIP_WRITE_BARRIER); SKIP_WRITE_BARRIER);
// Initialize NameDictionary elements. // Initialize NameDictionary elements.
result = BitcastTaggedToWord(result);
Node* start_address = IntPtrAdd( Node* start_address = IntPtrAdd(
result, IntPtrConstant(NameDictionary::OffsetOfElementAt( result, IntPtrConstant(NameDictionary::OffsetOfElementAt(
NameDictionary::kElementsStartIndex) - NameDictionary::kElementsStartIndex) -
...@@ -1772,13 +1774,12 @@ void CodeStubAssembler::StoreFieldsNoWriteBarrier(Node* start_address, ...@@ -1772,13 +1774,12 @@ void CodeStubAssembler::StoreFieldsNoWriteBarrier(Node* start_address,
Comment("StoreFieldsNoWriteBarrier"); Comment("StoreFieldsNoWriteBarrier");
CSA_ASSERT(WordIsWordAligned(start_address)); CSA_ASSERT(WordIsWordAligned(start_address));
CSA_ASSERT(WordIsWordAligned(end_address)); CSA_ASSERT(WordIsWordAligned(end_address));
BuildFastLoop(MachineType::PointerRepresentation(), start_address, BuildFastLoop(
end_address, MachineType::PointerRepresentation(), start_address, end_address,
[value](CodeStubAssembler* a, Node* current) { [value](CodeStubAssembler* a, Node* current) {
a->StoreNoWriteBarrier(MachineType::PointerRepresentation(), a->StoreNoWriteBarrier(MachineRepresentation::kTagged, current, value);
current, value); },
}, kPointerSize, IndexAdvanceMode::kPost);
kPointerSize, IndexAdvanceMode::kPost);
} }
Node* CodeStubAssembler::AllocateUninitializedJSArrayWithoutElements( Node* CodeStubAssembler::AllocateUninitializedJSArrayWithoutElements(
...@@ -4012,7 +4013,8 @@ Node* CodeStubAssembler::HashTableComputeCapacity(Node* at_least_space_for) { ...@@ -4012,7 +4013,8 @@ Node* CodeStubAssembler::HashTableComputeCapacity(Node* at_least_space_for) {
} }
Node* CodeStubAssembler::IntPtrMax(Node* left, Node* right) { Node* CodeStubAssembler::IntPtrMax(Node* left, Node* right) {
return Select(IntPtrGreaterThanOrEqual(left, right), left, right); return Select(IntPtrGreaterThanOrEqual(left, right), left, right,
MachineType::PointerRepresentation());
} }
template <typename Dictionary> template <typename Dictionary>
......
...@@ -446,12 +446,14 @@ class MachineRepresentationChecker { ...@@ -446,12 +446,14 @@ class MachineRepresentationChecker {
void CheckValueInputRepresentationIs(Node const* node, int index, void CheckValueInputRepresentationIs(Node const* node, int index,
MachineRepresentation representation) { MachineRepresentation representation) {
Node const* input = node->InputAt(index); Node const* input = node->InputAt(index);
if (inferrer_->GetRepresentation(input) != representation) { MachineRepresentation input_representation =
inferrer_->GetRepresentation(input);
if (input_representation != representation) {
std::stringstream str; std::stringstream str;
str << "TypeError: node #" << node->id() << ":" << *node->op() str << "TypeError: node #" << node->id() << ":" << *node->op() << ":"
<< " uses node #" << input->id() << ":" << *input->op() << MachineReprToString(input_representation) << " uses node #"
<< " which doesn't have a " << MachineReprToString(representation) << input->id() << ":" << *input->op() << " which doesn't have a "
<< " representation."; << MachineReprToString(representation) << " representation.";
FATAL(str.str().c_str()); FATAL(str.str().c_str());
} }
} }
...@@ -520,7 +522,9 @@ class MachineRepresentationChecker { ...@@ -520,7 +522,9 @@ class MachineRepresentationChecker {
void CheckValueInputForInt64Op(Node const* node, int index) { void CheckValueInputForInt64Op(Node const* node, int index) {
Node const* input = node->InputAt(index); Node const* input = node->InputAt(index);
switch (inferrer_->GetRepresentation(input)) { MachineRepresentation input_representation =
inferrer_->GetRepresentation(input);
switch (input_representation) {
case MachineRepresentation::kWord64: case MachineRepresentation::kWord64:
return; return;
case MachineRepresentation::kNone: { case MachineRepresentation::kNone: {
...@@ -535,9 +539,9 @@ class MachineRepresentationChecker { ...@@ -535,9 +539,9 @@ class MachineRepresentationChecker {
break; break;
} }
std::ostringstream str; std::ostringstream str;
str << "TypeError: node #" << node->id() << ":" << *node->op() str << "TypeError: node #" << node->id() << ":" << *node->op() << ":"
<< " uses node #" << input->id() << ":" << *input->op() << input_representation << " uses node #" << input->id() << ":"
<< " which doesn't have a kWord64 representation."; << *input->op() << " which doesn't have a kWord64 representation.";
FATAL(str.str().c_str()); FATAL(str.str().c_str());
} }
......
...@@ -36,7 +36,7 @@ class CodeAssemblerTesterImpl : private ZoneHolder, public CodeAssemblerT { ...@@ -36,7 +36,7 @@ class CodeAssemblerTesterImpl : private ZoneHolder, public CodeAssemblerT {
// Test generating code for a JS function (e.g. builtins). // Test generating code for a JS function (e.g. builtins).
CodeAssemblerTesterImpl(Isolate* isolate, int parameter_count, CodeAssemblerTesterImpl(Isolate* isolate, int parameter_count,
Code::Kind kind = Code::FUNCTION) Code::Kind kind = Code::BUILTIN)
: ZoneHolder(isolate), : ZoneHolder(isolate),
CodeAssemblerT(isolate, ZoneHolder::held_zone(), parameter_count, CodeAssemblerT(isolate, ZoneHolder::held_zone(), parameter_count,
Code::ComputeFlags(kind), "test"), Code::ComputeFlags(kind), "test"),
......
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