Commit 5420ae51 authored by cbruni's avatar cbruni Committed by Commit bot

[stubs] Add more helper methods for heap constants

Review-Url: https://codereview.chromium.org/2383473003
Cr-Commit-Position: refs/heads/master@{#39902}
parent ccd71204
...@@ -38,53 +38,23 @@ void CodeStubAssembler::Assert(Node* condition) { ...@@ -38,53 +38,23 @@ void CodeStubAssembler::Assert(Node* condition) {
#endif #endif
} }
Node* CodeStubAssembler::BooleanMapConstant() {
return HeapConstant(isolate()->factory()->boolean_map());
}
Node* CodeStubAssembler::EmptyStringConstant() {
return LoadRoot(Heap::kempty_stringRootIndex);
}
Node* CodeStubAssembler::FixedArrayMapConstant() {
return LoadRoot(Heap::kFixedArrayMapRootIndex);
}
Node* CodeStubAssembler::FixedCowArrayMapConstant() {
return LoadRoot(Heap::kFixedCOWArrayMapRootIndex);
}
Node* CodeStubAssembler::FixedDoubleArrayMapConstant() {
return LoadRoot(Heap::kFixedDoubleArrayMapRootIndex);
}
Node* CodeStubAssembler::HeapNumberMapConstant() {
return LoadRoot(Heap::kHeapNumberMapRootIndex);
}
Node* CodeStubAssembler::NoContextConstant() { Node* CodeStubAssembler::NoContextConstant() {
return SmiConstant(Smi::FromInt(0)); return SmiConstant(Smi::FromInt(0));
} }
Node* CodeStubAssembler::MinusZeroConstant() { #define HEAP_CONSTANT_ACCESSOR(rootName, name) \
return LoadRoot(Heap::kMinusZeroValueRootIndex); Node* CodeStubAssembler::name##Constant() { \
} return LoadRoot(Heap::k##rootName##RootIndex); \
}
Node* CodeStubAssembler::NanConstant() { HEAP_CONSTANT_LIST(HEAP_CONSTANT_ACCESSOR);
return LoadRoot(Heap::kNanValueRootIndex); #undef HEAP_CONSTANT_ACCESSOR
}
Node* CodeStubAssembler::NullConstant() {
return LoadRoot(Heap::kNullValueRootIndex);
}
Node* CodeStubAssembler::UndefinedConstant() {
return LoadRoot(Heap::kUndefinedValueRootIndex);
}
Node* CodeStubAssembler::TheHoleConstant() { #define HEAP_CONSTANT_TEST(rootName, name) \
return LoadRoot(Heap::kTheHoleValueRootIndex); Node* CodeStubAssembler::Is##name(Node* value) { \
} return WordEqual(value, name##Constant()); \
}
HEAP_CONSTANT_LIST(HEAP_CONSTANT_TEST);
#undef HEAP_CONSTANT_TEST
Node* CodeStubAssembler::HashSeed() { Node* CodeStubAssembler::HashSeed() {
return LoadAndUntagToWord32Root(Heap::kHashSeedRootIndex); return LoadAndUntagToWord32Root(Heap::kHashSeedRootIndex);
......
...@@ -25,6 +25,19 @@ enum class UnicodeEncoding { ...@@ -25,6 +25,19 @@ enum class UnicodeEncoding {
UTF32, // full UTF32 code unit / Unicode codepoint UTF32, // full UTF32 code unit / Unicode codepoint
}; };
#define HEAP_CONSTANT_LIST(V) \
V(BooleanMap, BooleanMap) \
V(empty_string, EmptyString) \
V(FixedArrayMap, FixedArrayMap) \
V(FixedCOWArrayMap, FixedCOWArrayMap) \
V(FixedDoubleArrayMap, FixedDoubleArrayMap) \
V(HeapNumberMap, HeapNumberMap) \
V(MinusZeroValue, MinusZero) \
V(NanValue, Nan) \
V(NullValue, Null) \
V(TheHoleValue, TheHole) \
V(UndefinedValue, Undefined)
// Provides JavaScript-specific "macro-assembler" functionality on top of the // Provides JavaScript-specific "macro-assembler" functionality on top of the
// CodeAssembler. By factoring the JavaScript-isms out of the CodeAssembler, // CodeAssembler. By factoring the JavaScript-isms out of the CodeAssembler,
// it's possible to add JavaScript-specific useful CodeAssembler "macros" // it's possible to add JavaScript-specific useful CodeAssembler "macros"
...@@ -76,18 +89,16 @@ class CodeStubAssembler : public compiler::CodeAssembler { ...@@ -76,18 +89,16 @@ class CodeStubAssembler : public compiler::CodeAssembler {
return value; return value;
} }
compiler::Node* BooleanMapConstant();
compiler::Node* EmptyStringConstant();
compiler::Node* FixedArrayMapConstant();
compiler::Node* FixedCowArrayMapConstant();
compiler::Node* FixedDoubleArrayMapConstant();
compiler::Node* HeapNumberMapConstant();
compiler::Node* NoContextConstant(); compiler::Node* NoContextConstant();
compiler::Node* NanConstant(); #define HEAP_CONSTANT_ACCESSOR(rootName, name) compiler::Node* name##Constant();
compiler::Node* NullConstant(); HEAP_CONSTANT_LIST(HEAP_CONSTANT_ACCESSOR)
compiler::Node* MinusZeroConstant(); #undef HEAP_CONSTANT_ACCESSOR
compiler::Node* UndefinedConstant();
compiler::Node* TheHoleConstant(); #define HEAP_CONSTANT_TEST(rootName, name) \
compiler::Node* Is##name(compiler::Node* value);
HEAP_CONSTANT_LIST(HEAP_CONSTANT_TEST)
#undef HEAP_CONSTANT_TEST
compiler::Node* HashSeed(); compiler::Node* HashSeed();
compiler::Node* StaleRegisterConstant(); compiler::Node* StaleRegisterConstant();
......
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