[turbofan] Remove JSGraph::Constant for Handles
Bug: v8:7790 Change-Id: I666f545f4b5b7b5aeaed4ce2910240ef54f40c0e Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1773251 Commit-Queue: Maya Lekova <mslekova@chromium.org> Reviewed-by: Georg Neis <neis@chromium.org> Cr-Commit-Position: refs/heads/master@{#63427}
This commit is contained in:
parent
1e5fe736d8
commit
9925079bb2
@ -14,11 +14,9 @@ namespace v8 {
|
|||||||
namespace internal {
|
namespace internal {
|
||||||
namespace compiler {
|
namespace compiler {
|
||||||
|
|
||||||
void AllocationBuilder::AllocateContext(int variadic_part_length,
|
void AllocationBuilder::AllocateContext(int variadic_part_length, MapRef map) {
|
||||||
Handle<Map> map) {
|
DCHECK(IsInRange(map.instance_type(), FIRST_CONTEXT_TYPE, LAST_CONTEXT_TYPE));
|
||||||
DCHECK(
|
DCHECK_NE(NATIVE_CONTEXT_TYPE, map.instance_type());
|
||||||
IsInRange(map->instance_type(), FIRST_CONTEXT_TYPE, LAST_CONTEXT_TYPE));
|
|
||||||
DCHECK_NE(NATIVE_CONTEXT_TYPE, map->instance_type());
|
|
||||||
int size = Context::SizeFor(variadic_part_length);
|
int size = Context::SizeFor(variadic_part_length);
|
||||||
Allocate(size, AllocationType::kYoung, Type::OtherInternal());
|
Allocate(size, AllocationType::kYoung, Type::OtherInternal());
|
||||||
Store(AccessBuilder::ForMap(), map);
|
Store(AccessBuilder::ForMap(), map);
|
||||||
@ -29,11 +27,11 @@ void AllocationBuilder::AllocateContext(int variadic_part_length,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Compound allocation of a FixedArray.
|
// Compound allocation of a FixedArray.
|
||||||
void AllocationBuilder::AllocateArray(int length, Handle<Map> map,
|
void AllocationBuilder::AllocateArray(int length, MapRef map,
|
||||||
AllocationType allocation) {
|
AllocationType allocation) {
|
||||||
DCHECK(map->instance_type() == FIXED_ARRAY_TYPE ||
|
DCHECK(map.instance_type() == FIXED_ARRAY_TYPE ||
|
||||||
map->instance_type() == FIXED_DOUBLE_ARRAY_TYPE);
|
map.instance_type() == FIXED_DOUBLE_ARRAY_TYPE);
|
||||||
int size = (map->instance_type() == FIXED_ARRAY_TYPE)
|
int size = (map.instance_type() == FIXED_ARRAY_TYPE)
|
||||||
? FixedArray::SizeFor(length)
|
? FixedArray::SizeFor(length)
|
||||||
: FixedDoubleArray::SizeFor(length);
|
: FixedDoubleArray::SizeFor(length);
|
||||||
Allocate(size, allocation, Type::OtherInternal());
|
Allocate(size, allocation, Type::OtherInternal());
|
||||||
|
@ -49,16 +49,12 @@ class AllocationBuilder final {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Compound allocation of a context.
|
// Compound allocation of a context.
|
||||||
inline void AllocateContext(int variadic_part_length, Handle<Map> map);
|
inline void AllocateContext(int variadic_part_length, MapRef map);
|
||||||
|
|
||||||
// Compound allocation of a FixedArray.
|
// Compound allocation of a FixedArray.
|
||||||
inline void AllocateArray(int length, Handle<Map> map,
|
inline void AllocateArray(int length, MapRef map,
|
||||||
AllocationType allocation = AllocationType::kYoung);
|
AllocationType allocation = AllocationType::kYoung);
|
||||||
|
|
||||||
// Compound store of a constant into a field.
|
|
||||||
void Store(const FieldAccess& access, Handle<Object> value) {
|
|
||||||
Store(access, jsgraph()->Constant(value));
|
|
||||||
}
|
|
||||||
// Compound store of a constant into a field.
|
// Compound store of a constant into a field.
|
||||||
void Store(const FieldAccess& access, const ObjectRef& value) {
|
void Store(const FieldAccess& access, const ObjectRef& value) {
|
||||||
Store(access, jsgraph()->Constant(value));
|
Store(access, jsgraph()->Constant(value));
|
||||||
|
@ -406,7 +406,7 @@ Reduction JSCreateLowering::ReduceJSCreateGeneratorObject(Node* node) {
|
|||||||
int size = parameter_count_no_receiver +
|
int size = parameter_count_no_receiver +
|
||||||
shared.GetBytecodeArray().register_count();
|
shared.GetBytecodeArray().register_count();
|
||||||
AllocationBuilder ab(jsgraph(), effect, control);
|
AllocationBuilder ab(jsgraph(), effect, control);
|
||||||
ab.AllocateArray(size, factory()->fixed_array_map());
|
ab.AllocateArray(size, MapRef(broker(), factory()->fixed_array_map()));
|
||||||
for (int i = 0; i < size; ++i) {
|
for (int i = 0; i < size; ++i) {
|
||||||
ab.Store(AccessBuilder::ForFixedArraySlot(i),
|
ab.Store(AccessBuilder::ForFixedArraySlot(i),
|
||||||
jsgraph()->UndefinedConstant());
|
jsgraph()->UndefinedConstant());
|
||||||
@ -762,7 +762,8 @@ Reduction JSCreateLowering::ReduceJSCreateAsyncFunctionObject(Node* node) {
|
|||||||
|
|
||||||
// Create the register file.
|
// Create the register file.
|
||||||
AllocationBuilder ab(jsgraph(), effect, control);
|
AllocationBuilder ab(jsgraph(), effect, control);
|
||||||
ab.AllocateArray(register_count, factory()->fixed_array_map());
|
ab.AllocateArray(register_count,
|
||||||
|
MapRef(broker(), factory()->fixed_array_map()));
|
||||||
for (int i = 0; i < register_count; ++i) {
|
for (int i = 0; i < register_count; ++i) {
|
||||||
ab.Store(AccessBuilder::ForFixedArraySlot(i),
|
ab.Store(AccessBuilder::ForFixedArraySlot(i),
|
||||||
jsgraph()->UndefinedConstant());
|
jsgraph()->UndefinedConstant());
|
||||||
@ -873,7 +874,7 @@ Reduction JSCreateLowering::ReduceJSCreateBoundFunction(Node* node) {
|
|||||||
Node* bound_arguments = jsgraph()->EmptyFixedArrayConstant();
|
Node* bound_arguments = jsgraph()->EmptyFixedArrayConstant();
|
||||||
if (arity > 0) {
|
if (arity > 0) {
|
||||||
AllocationBuilder a(jsgraph(), effect, control);
|
AllocationBuilder a(jsgraph(), effect, control);
|
||||||
a.AllocateArray(arity, factory()->fixed_array_map());
|
a.AllocateArray(arity, MapRef(broker(), factory()->fixed_array_map()));
|
||||||
for (int i = 0; i < arity; ++i) {
|
for (int i = 0; i < arity; ++i) {
|
||||||
a.Store(AccessBuilder::ForFixedArraySlot(i),
|
a.Store(AccessBuilder::ForFixedArraySlot(i),
|
||||||
NodeProperties::GetValueInput(node, 2 + i));
|
NodeProperties::GetValueInput(node, 2 + i));
|
||||||
@ -1019,7 +1020,7 @@ Reduction JSCreateLowering::ReduceJSCreateKeyValueArray(Node* node) {
|
|||||||
Node* length = jsgraph()->Constant(2);
|
Node* length = jsgraph()->Constant(2);
|
||||||
|
|
||||||
AllocationBuilder aa(jsgraph(), effect, graph()->start());
|
AllocationBuilder aa(jsgraph(), effect, graph()->start());
|
||||||
aa.AllocateArray(2, factory()->fixed_array_map());
|
aa.AllocateArray(2, MapRef(broker(), factory()->fixed_array_map()));
|
||||||
aa.Store(AccessBuilder::ForFixedArrayElement(PACKED_ELEMENTS),
|
aa.Store(AccessBuilder::ForFixedArrayElement(PACKED_ELEMENTS),
|
||||||
jsgraph()->ZeroConstant(), key);
|
jsgraph()->ZeroConstant(), key);
|
||||||
aa.Store(AccessBuilder::ForFixedArrayElement(PACKED_ELEMENTS),
|
aa.Store(AccessBuilder::ForFixedArrayElement(PACKED_ELEMENTS),
|
||||||
@ -1206,7 +1207,7 @@ Reduction JSCreateLowering::ReduceJSCreateFunctionContext(Node* node) {
|
|||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
a.AllocateContext(context_length, map);
|
a.AllocateContext(context_length, MapRef(broker(), map));
|
||||||
a.Store(AccessBuilder::ForContextSlot(Context::SCOPE_INFO_INDEX),
|
a.Store(AccessBuilder::ForContextSlot(Context::SCOPE_INFO_INDEX),
|
||||||
scope_info);
|
scope_info);
|
||||||
a.Store(AccessBuilder::ForContextSlot(Context::PREVIOUS_INDEX), context);
|
a.Store(AccessBuilder::ForContextSlot(Context::PREVIOUS_INDEX), context);
|
||||||
@ -1234,7 +1235,8 @@ Reduction JSCreateLowering::ReduceJSCreateWithContext(Node* node) {
|
|||||||
|
|
||||||
AllocationBuilder a(jsgraph(), effect, control);
|
AllocationBuilder a(jsgraph(), effect, control);
|
||||||
STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == 4); // Ensure fully covered.
|
STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == 4); // Ensure fully covered.
|
||||||
a.AllocateContext(Context::MIN_CONTEXT_SLOTS, factory()->with_context_map());
|
a.AllocateContext(Context::MIN_CONTEXT_SLOTS,
|
||||||
|
MapRef(broker(), factory()->with_context_map()));
|
||||||
a.Store(AccessBuilder::ForContextSlot(Context::SCOPE_INFO_INDEX), scope_info);
|
a.Store(AccessBuilder::ForContextSlot(Context::SCOPE_INFO_INDEX), scope_info);
|
||||||
a.Store(AccessBuilder::ForContextSlot(Context::PREVIOUS_INDEX), context);
|
a.Store(AccessBuilder::ForContextSlot(Context::PREVIOUS_INDEX), context);
|
||||||
a.Store(AccessBuilder::ForContextSlot(Context::EXTENSION_INDEX), extension);
|
a.Store(AccessBuilder::ForContextSlot(Context::EXTENSION_INDEX), extension);
|
||||||
@ -1257,7 +1259,7 @@ Reduction JSCreateLowering::ReduceJSCreateCatchContext(Node* node) {
|
|||||||
AllocationBuilder a(jsgraph(), effect, control);
|
AllocationBuilder a(jsgraph(), effect, control);
|
||||||
STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == 4); // Ensure fully covered.
|
STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == 4); // Ensure fully covered.
|
||||||
a.AllocateContext(Context::MIN_CONTEXT_SLOTS + 1,
|
a.AllocateContext(Context::MIN_CONTEXT_SLOTS + 1,
|
||||||
factory()->catch_context_map());
|
MapRef(broker(), factory()->catch_context_map()));
|
||||||
a.Store(AccessBuilder::ForContextSlot(Context::SCOPE_INFO_INDEX), scope_info);
|
a.Store(AccessBuilder::ForContextSlot(Context::SCOPE_INFO_INDEX), scope_info);
|
||||||
a.Store(AccessBuilder::ForContextSlot(Context::PREVIOUS_INDEX), context);
|
a.Store(AccessBuilder::ForContextSlot(Context::PREVIOUS_INDEX), context);
|
||||||
a.Store(AccessBuilder::ForContextSlot(Context::EXTENSION_INDEX), extension);
|
a.Store(AccessBuilder::ForContextSlot(Context::EXTENSION_INDEX), extension);
|
||||||
@ -1285,7 +1287,8 @@ Reduction JSCreateLowering::ReduceJSCreateBlockContext(Node* node) {
|
|||||||
|
|
||||||
AllocationBuilder a(jsgraph(), effect, control);
|
AllocationBuilder a(jsgraph(), effect, control);
|
||||||
STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == 4); // Ensure fully covered.
|
STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == 4); // Ensure fully covered.
|
||||||
a.AllocateContext(context_length, factory()->block_context_map());
|
a.AllocateContext(context_length,
|
||||||
|
MapRef(broker(), factory()->block_context_map()));
|
||||||
a.Store(AccessBuilder::ForContextSlot(Context::SCOPE_INFO_INDEX),
|
a.Store(AccessBuilder::ForContextSlot(Context::SCOPE_INFO_INDEX),
|
||||||
scope_info);
|
scope_info);
|
||||||
a.Store(AccessBuilder::ForContextSlot(Context::PREVIOUS_INDEX), context);
|
a.Store(AccessBuilder::ForContextSlot(Context::PREVIOUS_INDEX), context);
|
||||||
@ -1415,7 +1418,8 @@ Node* JSCreateLowering::AllocateArguments(Node* effect, Node* control,
|
|||||||
|
|
||||||
// Actually allocate the backing store.
|
// Actually allocate the backing store.
|
||||||
AllocationBuilder a(jsgraph(), effect, control);
|
AllocationBuilder a(jsgraph(), effect, control);
|
||||||
a.AllocateArray(argument_count, factory()->fixed_array_map());
|
a.AllocateArray(argument_count,
|
||||||
|
MapRef(broker(), factory()->fixed_array_map()));
|
||||||
for (int i = 0; i < argument_count; ++i, ++parameters_it) {
|
for (int i = 0; i < argument_count; ++i, ++parameters_it) {
|
||||||
DCHECK_NOT_NULL((*parameters_it).node);
|
DCHECK_NOT_NULL((*parameters_it).node);
|
||||||
a.Store(AccessBuilder::ForFixedArrayElement(), jsgraph()->Constant(i),
|
a.Store(AccessBuilder::ForFixedArrayElement(), jsgraph()->Constant(i),
|
||||||
@ -1446,7 +1450,7 @@ Node* JSCreateLowering::AllocateRestArguments(Node* effect, Node* control,
|
|||||||
|
|
||||||
// Actually allocate the backing store.
|
// Actually allocate the backing store.
|
||||||
AllocationBuilder a(jsgraph(), effect, control);
|
AllocationBuilder a(jsgraph(), effect, control);
|
||||||
a.AllocateArray(num_elements, factory()->fixed_array_map());
|
a.AllocateArray(num_elements, MapRef(broker(), factory()->fixed_array_map()));
|
||||||
for (int i = 0; i < num_elements; ++i, ++parameters_it) {
|
for (int i = 0; i < num_elements; ++i, ++parameters_it) {
|
||||||
DCHECK_NOT_NULL((*parameters_it).node);
|
DCHECK_NOT_NULL((*parameters_it).node);
|
||||||
a.Store(AccessBuilder::ForFixedArrayElement(), jsgraph()->Constant(i),
|
a.Store(AccessBuilder::ForFixedArrayElement(), jsgraph()->Constant(i),
|
||||||
@ -1485,7 +1489,8 @@ Node* JSCreateLowering::AllocateAliasedArguments(
|
|||||||
// another indirection away and then linked into the parameter map below,
|
// another indirection away and then linked into the parameter map below,
|
||||||
// whereas mapped argument values are replaced with a hole instead.
|
// whereas mapped argument values are replaced with a hole instead.
|
||||||
AllocationBuilder aa(jsgraph(), effect, control);
|
AllocationBuilder aa(jsgraph(), effect, control);
|
||||||
aa.AllocateArray(argument_count, factory()->fixed_array_map());
|
aa.AllocateArray(argument_count,
|
||||||
|
MapRef(broker(), factory()->fixed_array_map()));
|
||||||
for (int i = 0; i < mapped_count; ++i, ++parameters_it) {
|
for (int i = 0; i < mapped_count; ++i, ++parameters_it) {
|
||||||
aa.Store(AccessBuilder::ForFixedArrayElement(), jsgraph()->Constant(i),
|
aa.Store(AccessBuilder::ForFixedArrayElement(), jsgraph()->Constant(i),
|
||||||
jsgraph()->TheHoleConstant());
|
jsgraph()->TheHoleConstant());
|
||||||
@ -1499,7 +1504,8 @@ Node* JSCreateLowering::AllocateAliasedArguments(
|
|||||||
|
|
||||||
// Actually allocate the backing store.
|
// Actually allocate the backing store.
|
||||||
AllocationBuilder a(jsgraph(), arguments, control);
|
AllocationBuilder a(jsgraph(), arguments, control);
|
||||||
a.AllocateArray(mapped_count + 2, factory()->sloppy_arguments_elements_map());
|
a.AllocateArray(mapped_count + 2,
|
||||||
|
MapRef(broker(), factory()->sloppy_arguments_elements_map()));
|
||||||
a.Store(AccessBuilder::ForFixedArrayElement(), jsgraph()->Constant(0),
|
a.Store(AccessBuilder::ForFixedArrayElement(), jsgraph()->Constant(0),
|
||||||
context);
|
context);
|
||||||
a.Store(AccessBuilder::ForFixedArrayElement(), jsgraph()->Constant(1),
|
a.Store(AccessBuilder::ForFixedArrayElement(), jsgraph()->Constant(1),
|
||||||
@ -1544,7 +1550,8 @@ Node* JSCreateLowering::AllocateAliasedArguments(
|
|||||||
|
|
||||||
// Actually allocate the backing store.
|
// Actually allocate the backing store.
|
||||||
AllocationBuilder a(jsgraph(), arguments, control);
|
AllocationBuilder a(jsgraph(), arguments, control);
|
||||||
a.AllocateArray(mapped_count + 2, factory()->sloppy_arguments_elements_map());
|
a.AllocateArray(mapped_count + 2,
|
||||||
|
MapRef(broker(), factory()->sloppy_arguments_elements_map()));
|
||||||
a.Store(AccessBuilder::ForFixedArrayElement(), jsgraph()->Constant(0),
|
a.Store(AccessBuilder::ForFixedArrayElement(), jsgraph()->Constant(0),
|
||||||
context);
|
context);
|
||||||
a.Store(AccessBuilder::ForFixedArrayElement(), jsgraph()->Constant(1),
|
a.Store(AccessBuilder::ForFixedArrayElement(), jsgraph()->Constant(1),
|
||||||
@ -1579,7 +1586,7 @@ Node* JSCreateLowering::AllocateElements(Node* effect, Node* control,
|
|||||||
|
|
||||||
// Actually allocate the backing store.
|
// Actually allocate the backing store.
|
||||||
AllocationBuilder a(jsgraph(), effect, control);
|
AllocationBuilder a(jsgraph(), effect, control);
|
||||||
a.AllocateArray(capacity, elements_map, allocation);
|
a.AllocateArray(capacity, MapRef(broker(), elements_map), allocation);
|
||||||
for (int i = 0; i < capacity; ++i) {
|
for (int i = 0; i < capacity; ++i) {
|
||||||
Node* index = jsgraph()->Constant(i);
|
Node* index = jsgraph()->Constant(i);
|
||||||
a.Store(access, index, value);
|
a.Store(access, index, value);
|
||||||
@ -1604,7 +1611,7 @@ Node* JSCreateLowering::AllocateElements(Node* effect, Node* control,
|
|||||||
|
|
||||||
// Actually allocate the backing store.
|
// Actually allocate the backing store.
|
||||||
AllocationBuilder a(jsgraph(), effect, control);
|
AllocationBuilder a(jsgraph(), effect, control);
|
||||||
a.AllocateArray(capacity, elements_map, allocation);
|
a.AllocateArray(capacity, MapRef(broker(), elements_map), allocation);
|
||||||
for (int i = 0; i < capacity; ++i) {
|
for (int i = 0; i < capacity; ++i) {
|
||||||
Node* index = jsgraph()->Constant(i);
|
Node* index = jsgraph()->Constant(i);
|
||||||
a.Store(access, index, values[i]);
|
a.Store(access, index, values[i]);
|
||||||
@ -1670,7 +1677,8 @@ Node* JSCreateLowering::AllocateFastLiteral(Node* effect, Node* control,
|
|||||||
// Allocate a mutable HeapNumber box and store the value into it.
|
// Allocate a mutable HeapNumber box and store the value into it.
|
||||||
AllocationBuilder builder(jsgraph(), effect, control);
|
AllocationBuilder builder(jsgraph(), effect, control);
|
||||||
builder.Allocate(HeapNumber::kSize, allocation);
|
builder.Allocate(HeapNumber::kSize, allocation);
|
||||||
builder.Store(AccessBuilder::ForMap(), factory()->heap_number_map());
|
builder.Store(AccessBuilder::ForMap(),
|
||||||
|
MapRef(broker(), factory()->heap_number_map()));
|
||||||
builder.Store(AccessBuilder::ForHeapNumberValue(),
|
builder.Store(AccessBuilder::ForHeapNumberValue(),
|
||||||
jsgraph()->Constant(number));
|
jsgraph()->Constant(number));
|
||||||
value = effect = builder.Finish();
|
value = effect = builder.Finish();
|
||||||
@ -1763,7 +1771,7 @@ Node* JSCreateLowering::AllocateFastLiteralElements(Node* effect, Node* control,
|
|||||||
|
|
||||||
// Allocate the backing store array and store the elements.
|
// Allocate the backing store array and store the elements.
|
||||||
AllocationBuilder builder(jsgraph(), effect, control);
|
AllocationBuilder builder(jsgraph(), effect, control);
|
||||||
builder.AllocateArray(elements_length, elements_map.object(), allocation);
|
builder.AllocateArray(elements_length, elements_map, allocation);
|
||||||
ElementAccess const access =
|
ElementAccess const access =
|
||||||
(elements_map.instance_type() == FIXED_DOUBLE_ARRAY_TYPE)
|
(elements_map.instance_type() == FIXED_DOUBLE_ARRAY_TYPE)
|
||||||
? AccessBuilder::ForFixedDoubleArrayElement()
|
? AccessBuilder::ForFixedDoubleArrayElement()
|
||||||
|
@ -46,26 +46,6 @@ Node* JSGraph::CEntryStubConstant(int result_size, SaveFPRegsMode save_doubles,
|
|||||||
argv_mode, builtin_exit_frame));
|
argv_mode, builtin_exit_frame));
|
||||||
}
|
}
|
||||||
|
|
||||||
Node* JSGraph::Constant(Handle<Object> value) {
|
|
||||||
// Dereference the handle to determine if a number constant or other
|
|
||||||
// canonicalized node can be used.
|
|
||||||
if (value->IsNumber()) {
|
|
||||||
return Constant(value->Number());
|
|
||||||
} else if (value->IsUndefined(isolate())) {
|
|
||||||
return UndefinedConstant();
|
|
||||||
} else if (value->IsTrue(isolate())) {
|
|
||||||
return TrueConstant();
|
|
||||||
} else if (value->IsFalse(isolate())) {
|
|
||||||
return FalseConstant();
|
|
||||||
} else if (value->IsNull(isolate())) {
|
|
||||||
return NullConstant();
|
|
||||||
} else if (value->IsTheHole(isolate())) {
|
|
||||||
return TheHoleConstant();
|
|
||||||
} else {
|
|
||||||
return HeapConstant(Handle<HeapObject>::cast(value));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Node* JSGraph::Constant(const ObjectRef& ref) {
|
Node* JSGraph::Constant(const ObjectRef& ref) {
|
||||||
if (ref.IsSmi()) return Constant(ref.AsSmi());
|
if (ref.IsSmi()) return Constant(ref.AsSmi());
|
||||||
OddballType oddball_type =
|
OddballType oddball_type =
|
||||||
|
@ -46,16 +46,12 @@ class V8_EXPORT_PRIVATE JSGraph : public MachineGraph {
|
|||||||
// Used for stubs and runtime functions with no context. (alias: SMI zero)
|
// Used for stubs and runtime functions with no context. (alias: SMI zero)
|
||||||
Node* NoContextConstant() { return ZeroConstant(); }
|
Node* NoContextConstant() { return ZeroConstant(); }
|
||||||
|
|
||||||
// Creates a HeapConstant node, possibly canonicalized, and may access the
|
// Creates a HeapConstant node, possibly canonicalized.
|
||||||
// heap to inspect the object.
|
|
||||||
Node* HeapConstant(Handle<HeapObject> value);
|
Node* HeapConstant(Handle<HeapObject> value);
|
||||||
|
|
||||||
// Creates a Constant node of the appropriate type for the given object.
|
// Creates a Constant node of the appropriate type for the given object.
|
||||||
// Accesses the heap to inspect the object and determine whether one of the
|
// Inspect the (serialized) object and determine whether one of the
|
||||||
// canonicalized globals or a number constant should be returned.
|
// canonicalized globals or a number constant should be returned.
|
||||||
Node* Constant(Handle<Object> value);
|
|
||||||
|
|
||||||
// Like above, but doesn't access the heap directly.
|
|
||||||
Node* Constant(const ObjectRef& value);
|
Node* Constant(const ObjectRef& value);
|
||||||
|
|
||||||
// Creates a NumberConstant node, usually canonicalized.
|
// Creates a NumberConstant node, usually canonicalized.
|
||||||
|
@ -2268,7 +2268,8 @@ JSNativeContextSpecialization::BuildPropertyStore(
|
|||||||
AllocationBuilder a(jsgraph(), effect, control);
|
AllocationBuilder a(jsgraph(), effect, control);
|
||||||
a.Allocate(HeapNumber::kSize, AllocationType::kYoung,
|
a.Allocate(HeapNumber::kSize, AllocationType::kYoung,
|
||||||
Type::OtherInternal());
|
Type::OtherInternal());
|
||||||
a.Store(AccessBuilder::ForMap(), factory()->heap_number_map());
|
a.Store(AccessBuilder::ForMap(),
|
||||||
|
MapRef(broker(), factory()->heap_number_map()));
|
||||||
FieldAccess value_field_access =
|
FieldAccess value_field_access =
|
||||||
AccessBuilder::ForHeapNumberValue();
|
AccessBuilder::ForHeapNumberValue();
|
||||||
value_field_access.const_field_info = field_access.const_field_info;
|
value_field_access.const_field_info = field_access.const_field_info;
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include "src/codegen/assembler.h"
|
#include "src/codegen/assembler.h"
|
||||||
#include "src/compiler/js-graph.h"
|
#include "src/compiler/js-graph.h"
|
||||||
|
#include "src/compiler/js-heap-broker.h"
|
||||||
#include "src/compiler/node-properties.h"
|
#include "src/compiler/node-properties.h"
|
||||||
#include "src/heap/factory-inl.h"
|
#include "src/heap/factory-inl.h"
|
||||||
#include "test/cctest/cctest.h"
|
#include "test/cctest/cctest.h"
|
||||||
@ -35,7 +36,9 @@ class JSConstantCacheTester : public HandleAndZoneScope,
|
|||||||
JSConstantCacheTester()
|
JSConstantCacheTester()
|
||||||
: JSCacheTesterHelper(main_zone()),
|
: JSCacheTesterHelper(main_zone()),
|
||||||
JSGraph(main_isolate(), &main_graph_, &main_common_, &main_javascript_,
|
JSGraph(main_isolate(), &main_graph_, &main_common_, &main_javascript_,
|
||||||
nullptr, &main_machine_) {
|
nullptr, &main_machine_),
|
||||||
|
canonical_(main_isolate()),
|
||||||
|
broker_(main_isolate(), main_zone(), false) {
|
||||||
main_graph_.SetStart(main_graph_.NewNode(common()->Start(0)));
|
main_graph_.SetStart(main_graph_.NewNode(common()->Start(0)));
|
||||||
main_graph_.SetEnd(
|
main_graph_.SetEnd(
|
||||||
main_graph_.NewNode(common()->End(1), main_graph_.start()));
|
main_graph_.NewNode(common()->End(1), main_graph_.start()));
|
||||||
@ -47,6 +50,11 @@ class JSConstantCacheTester : public HandleAndZoneScope,
|
|||||||
}
|
}
|
||||||
|
|
||||||
Factory* factory() { return main_isolate()->factory(); }
|
Factory* factory() { return main_isolate()->factory(); }
|
||||||
|
JSHeapBroker* broker() { return &broker_; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
CanonicalHandleScope canonical_;
|
||||||
|
JSHeapBroker broker_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -182,8 +190,8 @@ TEST(HeapNumbers) {
|
|||||||
Handle<Object> num = T.factory()->NewNumber(value);
|
Handle<Object> num = T.factory()->NewNumber(value);
|
||||||
Handle<HeapNumber> heap = T.factory()->NewHeapNumber(value);
|
Handle<HeapNumber> heap = T.factory()->NewHeapNumber(value);
|
||||||
Node* node1 = T.Constant(value);
|
Node* node1 = T.Constant(value);
|
||||||
Node* node2 = T.Constant(num);
|
Node* node2 = T.Constant(ObjectRef(T.broker(), num));
|
||||||
Node* node3 = T.Constant(heap);
|
Node* node3 = T.Constant(ObjectRef(T.broker(), heap));
|
||||||
CHECK_EQ(node1, node2);
|
CHECK_EQ(node1, node2);
|
||||||
CHECK_EQ(node1, node3);
|
CHECK_EQ(node1, node3);
|
||||||
}
|
}
|
||||||
@ -193,12 +201,18 @@ TEST(HeapNumbers) {
|
|||||||
TEST(OddballHandle) {
|
TEST(OddballHandle) {
|
||||||
JSConstantCacheTester T;
|
JSConstantCacheTester T;
|
||||||
|
|
||||||
CHECK_EQ(T.UndefinedConstant(), T.Constant(T.factory()->undefined_value()));
|
CHECK_EQ(T.UndefinedConstant(),
|
||||||
CHECK_EQ(T.TheHoleConstant(), T.Constant(T.factory()->the_hole_value()));
|
T.Constant(ObjectRef(T.broker(), T.factory()->undefined_value())));
|
||||||
CHECK_EQ(T.TrueConstant(), T.Constant(T.factory()->true_value()));
|
CHECK_EQ(T.TheHoleConstant(),
|
||||||
CHECK_EQ(T.FalseConstant(), T.Constant(T.factory()->false_value()));
|
T.Constant(ObjectRef(T.broker(), T.factory()->the_hole_value())));
|
||||||
CHECK_EQ(T.NullConstant(), T.Constant(T.factory()->null_value()));
|
CHECK_EQ(T.TrueConstant(),
|
||||||
CHECK_EQ(T.NaNConstant(), T.Constant(T.factory()->nan_value()));
|
T.Constant(ObjectRef(T.broker(), T.factory()->true_value())));
|
||||||
|
CHECK_EQ(T.FalseConstant(),
|
||||||
|
T.Constant(ObjectRef(T.broker(), T.factory()->false_value())));
|
||||||
|
CHECK_EQ(T.NullConstant(),
|
||||||
|
T.Constant(ObjectRef(T.broker(), T.factory()->null_value())));
|
||||||
|
CHECK_EQ(T.NaNConstant(),
|
||||||
|
T.Constant(ObjectRef(T.broker(), T.factory()->nan_value())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,6 +52,8 @@ class ContextSpecializationTester : public HandleAndZoneScope {
|
|||||||
void CheckContextInputAndDepthChanges(Node* node, Node* expected_new_context,
|
void CheckContextInputAndDepthChanges(Node* node, Node* expected_new_context,
|
||||||
size_t expected_new_depth);
|
size_t expected_new_depth);
|
||||||
|
|
||||||
|
JSHeapBroker* broker() { return &js_heap_broker_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TickCounter tick_counter_;
|
TickCounter tick_counter_;
|
||||||
CanonicalHandleScope canonical_;
|
CanonicalHandleScope canonical_;
|
||||||
@ -126,8 +128,9 @@ TEST(ReduceJSLoadContext0) {
|
|||||||
const int slot = Context::NATIVE_CONTEXT_INDEX;
|
const int slot = Context::NATIVE_CONTEXT_INDEX;
|
||||||
native->set(slot, *expected);
|
native->set(slot, *expected);
|
||||||
|
|
||||||
Node* const_context = t.jsgraph()->Constant(native);
|
Node* const_context = t.jsgraph()->Constant(ObjectRef(t.broker(), native));
|
||||||
Node* deep_const_context = t.jsgraph()->Constant(subcontext2);
|
Node* deep_const_context =
|
||||||
|
t.jsgraph()->Constant(ObjectRef(t.broker(), subcontext2));
|
||||||
Node* param_context = t.graph()->NewNode(t.common()->Parameter(0), start);
|
Node* param_context = t.graph()->NewNode(t.common()->Parameter(0), start);
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -269,7 +272,8 @@ TEST(ReduceJSLoadContext2) {
|
|||||||
context_object0->set(slot_index, *slot_value0);
|
context_object0->set(slot_index, *slot_value0);
|
||||||
context_object1->set(slot_index, *slot_value1);
|
context_object1->set(slot_index, *slot_value1);
|
||||||
|
|
||||||
Node* context0 = t.jsgraph()->Constant(context_object1);
|
Node* context0 =
|
||||||
|
t.jsgraph()->Constant(ObjectRef(t.broker(), context_object1));
|
||||||
Node* context1 =
|
Node* context1 =
|
||||||
t.graph()->NewNode(create_function_context, context0, start, start);
|
t.graph()->NewNode(create_function_context, context0, start, start);
|
||||||
Node* context2 =
|
Node* context2 =
|
||||||
@ -423,8 +427,9 @@ TEST(ReduceJSStoreContext0) {
|
|||||||
const int slot = Context::NATIVE_CONTEXT_INDEX;
|
const int slot = Context::NATIVE_CONTEXT_INDEX;
|
||||||
native->set(slot, *expected);
|
native->set(slot, *expected);
|
||||||
|
|
||||||
Node* const_context = t.jsgraph()->Constant(native);
|
Node* const_context = t.jsgraph()->Constant(ObjectRef(t.broker(), native));
|
||||||
Node* deep_const_context = t.jsgraph()->Constant(subcontext2);
|
Node* deep_const_context =
|
||||||
|
t.jsgraph()->Constant(ObjectRef(t.broker(), subcontext2));
|
||||||
Node* param_context = t.graph()->NewNode(t.common()->Parameter(0), start);
|
Node* param_context = t.graph()->NewNode(t.common()->Parameter(0), start);
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -531,7 +536,8 @@ TEST(ReduceJSStoreContext2) {
|
|||||||
context_object0->set(slot_index, *slot_value0);
|
context_object0->set(slot_index, *slot_value0);
|
||||||
context_object1->set(slot_index, *slot_value1);
|
context_object1->set(slot_index, *slot_value1);
|
||||||
|
|
||||||
Node* context0 = t.jsgraph()->Constant(context_object1);
|
Node* context0 =
|
||||||
|
t.jsgraph()->Constant(ObjectRef(t.broker(), context_object1));
|
||||||
Node* context1 =
|
Node* context1 =
|
||||||
t.graph()->NewNode(create_function_context, context0, start, start);
|
t.graph()->NewNode(create_function_context, context0, start, start);
|
||||||
Node* context2 =
|
Node* context2 =
|
||||||
|
Loading…
Reference in New Issue
Block a user