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) {
#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() {
return SmiConstant(Smi::FromInt(0));
}
Node* CodeStubAssembler::MinusZeroConstant() {
return LoadRoot(Heap::kMinusZeroValueRootIndex);
}
Node* CodeStubAssembler::NanConstant() {
return LoadRoot(Heap::kNanValueRootIndex);
}
Node* CodeStubAssembler::NullConstant() {
return LoadRoot(Heap::kNullValueRootIndex);
}
Node* CodeStubAssembler::UndefinedConstant() {
return LoadRoot(Heap::kUndefinedValueRootIndex);
}
#define HEAP_CONSTANT_ACCESSOR(rootName, name) \
Node* CodeStubAssembler::name##Constant() { \
return LoadRoot(Heap::k##rootName##RootIndex); \
}
HEAP_CONSTANT_LIST(HEAP_CONSTANT_ACCESSOR);
#undef HEAP_CONSTANT_ACCESSOR
Node* CodeStubAssembler::TheHoleConstant() {
return LoadRoot(Heap::kTheHoleValueRootIndex);
}
#define HEAP_CONSTANT_TEST(rootName, name) \
Node* CodeStubAssembler::Is##name(Node* value) { \
return WordEqual(value, name##Constant()); \
}
HEAP_CONSTANT_LIST(HEAP_CONSTANT_TEST);
#undef HEAP_CONSTANT_TEST
Node* CodeStubAssembler::HashSeed() {
return LoadAndUntagToWord32Root(Heap::kHashSeedRootIndex);
......
......@@ -25,6 +25,19 @@ enum class UnicodeEncoding {
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
// CodeAssembler. By factoring the JavaScript-isms out of the CodeAssembler,
// it's possible to add JavaScript-specific useful CodeAssembler "macros"
......@@ -76,18 +89,16 @@ class CodeStubAssembler : public compiler::CodeAssembler {
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* NanConstant();
compiler::Node* NullConstant();
compiler::Node* MinusZeroConstant();
compiler::Node* UndefinedConstant();
compiler::Node* TheHoleConstant();
#define HEAP_CONSTANT_ACCESSOR(rootName, name) compiler::Node* name##Constant();
HEAP_CONSTANT_LIST(HEAP_CONSTANT_ACCESSOR)
#undef HEAP_CONSTANT_ACCESSOR
#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* 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