Commit 00680272 authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[turbofan] Move {Code} flag setting into allocator.

This makes sure flags on newly allocated {Code} objects are initialized
from within the allocator itself instead of after the object has been
created. It essentially makes these flags immutable.

R=jarin@chromium.org
BUG=v8:6792

Change-Id: I6bef183a25508faf1fec28d347956e766e65aecf
Reviewed-on: https://chromium-review.googlesource.com/737633
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48933}
parent e5f064d3
...@@ -304,14 +304,12 @@ Handle<Code> CodeGenerator::FinalizeCode() { ...@@ -304,14 +304,12 @@ Handle<Code> CodeGenerator::FinalizeCode() {
unwinding_info_writer_.eh_frame_writer()->GetEhFrame(&desc); unwinding_info_writer_.eh_frame_writer()->GetEhFrame(&desc);
} }
Handle<Code> result = Handle<Code> result = isolate()->factory()->NewCode(
isolate()->factory()->NewCode(desc, info()->code_kind(), Handle<Object>(), desc, info()->code_kind(), Handle<Object>(), table, source_positions,
table, source_positions, deopt_data, false); deopt_data, false, true, frame()->GetTotalFrameSlotCount(),
safepoints()->GetCodeOffset());
isolate()->counters()->total_compiled_code_size()->Increment( isolate()->counters()->total_compiled_code_size()->Increment(
result->instruction_size()); result->instruction_size());
result->set_is_turbofanned(true);
result->set_stack_slots(frame()->GetTotalFrameSlotCount());
result->set_safepoint_table_offset(safepoints()->GetCodeOffset());
LOG_CODE_EVENT(isolate(), LOG_CODE_EVENT(isolate(),
CodeLinePosInfoRecordEvent(*Handle<AbstractCode>::cast(result), CodeLinePosInfoRecordEvent(*Handle<AbstractCode>::cast(result),
......
...@@ -1794,7 +1794,8 @@ Handle<Code> Factory::NewCode( ...@@ -1794,7 +1794,8 @@ Handle<Code> Factory::NewCode(
const CodeDesc& desc, Code::Kind kind, Handle<Object> self_ref, const CodeDesc& desc, Code::Kind kind, Handle<Object> self_ref,
MaybeHandle<HandlerTable> maybe_handler_table, MaybeHandle<HandlerTable> maybe_handler_table,
MaybeHandle<ByteArray> maybe_source_position_table, MaybeHandle<ByteArray> maybe_source_position_table,
MaybeHandle<DeoptimizationData> maybe_deopt_data, bool immovable) { MaybeHandle<DeoptimizationData> maybe_deopt_data, bool immovable,
bool is_turbofanned, int stack_slots, int safepoint_table_offset) {
Handle<ByteArray> reloc_info = NewByteArray(desc.reloc_size, TENURED); Handle<ByteArray> reloc_info = NewByteArray(desc.reloc_size, TENURED);
Handle<CodeDataContainer> data_container = NewCodeDataContainer(0); Handle<CodeDataContainer> data_container = NewCodeDataContainer(0);
...@@ -1836,7 +1837,9 @@ Handle<Code> Factory::NewCode( ...@@ -1836,7 +1837,9 @@ Handle<Code> Factory::NewCode(
code->set_relocation_info(*reloc_info); code->set_relocation_info(*reloc_info);
code->initialize_flags(kind); code->initialize_flags(kind);
code->set_has_unwinding_info(has_unwinding_info); code->set_has_unwinding_info(has_unwinding_info);
code->set_safepoint_table_offset(0); code->set_is_turbofanned(is_turbofanned);
code->set_stack_slots(stack_slots);
code->set_safepoint_table_offset(safepoint_table_offset);
code->set_code_data_container(*data_container); code->set_code_data_container(*data_container);
code->set_has_tagged_params(true); code->set_has_tagged_params(true);
code->set_deoptimization_data(*deopt_data); code->set_deoptimization_data(*deopt_data);
......
...@@ -685,7 +685,8 @@ class V8_EXPORT_PRIVATE Factory final { ...@@ -685,7 +685,8 @@ class V8_EXPORT_PRIVATE Factory final {
MaybeHandle<ByteArray>(), MaybeHandle<ByteArray>(),
MaybeHandle<DeoptimizationData> maybe_deopt_data = MaybeHandle<DeoptimizationData> maybe_deopt_data =
MaybeHandle<DeoptimizationData>(), MaybeHandle<DeoptimizationData>(),
bool immovable = false); bool immovable = false, bool is_turbofanned = false,
int stack_slots = 0, int safepoint_table_offset = 0);
// Allocates a new, empty code object for use by builtin deserialization. The // Allocates a new, empty code object for use by builtin deserialization. The
// given {size} argument specifies the size of the entire code object. // given {size} argument specifies the size of the entire code object.
......
...@@ -420,7 +420,7 @@ unsigned Code::stack_slots() const { ...@@ -420,7 +420,7 @@ unsigned Code::stack_slots() const {
void Code::set_stack_slots(unsigned slots) { void Code::set_stack_slots(unsigned slots) {
CHECK(slots <= StackSlotsField::kMax); CHECK(slots <= StackSlotsField::kMax);
DCHECK(is_turbofanned()); DCHECK(is_turbofanned() || slots == 0); // Allow zero initialization.
int previous = READ_UINT32_FIELD(this, kFlagsOffset); int previous = READ_UINT32_FIELD(this, kFlagsOffset);
int updated = StackSlotsField::update(previous, slots); int updated = StackSlotsField::update(previous, slots);
WRITE_UINT32_FIELD(this, kFlagsOffset, updated); WRITE_UINT32_FIELD(this, kFlagsOffset, updated);
......
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