Reviewers: William Hesse,
Description:
Enable compilation of very simple functions in x64 crankshaft.
This change includes support for safepointtables and adding deoptimization
info
(but not for deoptimizing).
Implemented crankshaft functions:
CallCode
GenerateSafepointTable
RegisterEnvironmentForDeoptimization
EmitGoto
This change allows us to compile very simple functions with crankshaft:
An empty function
A function returning a constant.
A function returning a parameter.
There is 6 disabled tests that require us to be able to deoptimize
which is currently not supported.
Please review this at http://codereview.chromium.org/6310009/
SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/
Affected files:
M src/x64/assembler-x64.h
M src/x64/assembler-x64.cc
M src/x64/deoptimizer-x64.cc
M src/x64/frames-x64.h
M src/x64/lithium-codegen-x64.cc
M test/cctest/cctest.status
M test/mjsunit/mjsunit.status
Index: src/x64/assembler-x64.cc
===================================================================
--- src/x64/assembler-x64.cc (revision 6340)
+++ src/x64/assembler-x64.cc (working copy)
@@ -2950,6 +2950,12 @@
}
+void Assembler::db(uint8_t data) {
+ EnsureSpace ensure_space(this);
+ emit(data);
+}
+
+
void Assembler::dd(uint32_t data) {
EnsureSpace ensure_space(this);
emitl(data);
Index: src/x64/assembler-x64.h
===================================================================
--- src/x64/assembler-x64.h (revision 6340)
+++ src/x64/assembler-x64.h (working copy)
@@ -1261,7 +1261,7 @@
// Writes a single word of data in the code stream.
// Used for inline tables, e.g., jump-tables.
- void db(uint8_t data) { UNIMPLEMENTED(); }
+ void db(uint8_t data);
void dd(uint32_t data);
int pc_offset() const { return static_cast<int>(pc_ - buffer_); }
Index: src/x64/deoptimizer-x64.cc
===================================================================
--- src/x64/deoptimizer-x64.cc (revision 6340)
+++ src/x64/deoptimizer-x64.cc (working copy)
@@ -41,7 +41,8 @@
int Deoptimizer::table_entry_size_ = 10;
void Deoptimizer::DeoptimizeFunction(JSFunction* function) {
- UNIMPLEMENTED();
+ // UNIMPLEMTED, for now just return.
+ return;
}
@@ -68,7 +69,8 @@
void Deoptimizer::EntryGenerator::Generate() {
- UNIMPLEMENTED();
+ // UNIMPLEMTED, for now just return.
+ return;
}
Index: src/x64/frames-x64.h
===================================================================
--- src/x64/frames-x64.h (revision 6340)
+++ src/x64/frames-x64.h (working copy)
@@ -45,7 +45,7 @@
// Number of registers for which space is reserved in safepoints.
// TODO(x64): This should not be 0.
-static const int kNumSafepointRegisters = 0;
+static const int kNumSafepointRegisters = 8;
// ----------------------------------------------------
Index: src/x64/lithium-codegen-x64.cc
===================================================================
--- src/x64/lithium-codegen-x64.cc (revision 6340)
+++ src/x64/lithium-codegen-x64.cc (working copy)
@@ -338,8 +338,9 @@
bool LCodeGen::GenerateSafepointTable() {
- Abort("Unimplemented: %s", "GeneratePrologue");
- return false;
+ ASSERT(is_done());
+ safepoints_.Emit(masm(), StackSlotCount());
+ return !is_aborted();
}
@@ -492,7 +493,24 @@
void LCodeGen::CallCode(Handle<Code> code,
RelocInfo::Mode mode,
LInstruction* instr) {
- Abort("Unimplemented: %s", "CallCode");
+ if (instr != NULL) {
+ LPointerMap* pointers = instr->pointer_map();
+ RecordPosition(pointers->position());
+ __ call(code, mode);
+ RegisterLazyDeoptimization(instr);
+ } else {
+ LPointerMap no_pointers(0);
+ RecordPosition(no_pointers.position());
+ __ call(code, mode);
+ RecordSafepoint(&no_pointers, Safepoint::kNoDeoptimizationIndex);
+ }
+
+ // Signal that we don't inline smi code before these stubs in the
+ // optimizing code generator.
+ if (code->kind() == Code::TYPE_RECORDING_BINARY_OP_IC ||
+ code->kind() == Code::COMPARE_IC) {
+ __ nop();
+ }
}
@@ -521,7 +539,30 @@
void LCodeGen::RegisterEnvironmentForDeoptimization(LEnvironment*
environment) {
- Abort("Unimplemented: %s", "RegisterEnvironmentForDeoptimization");
+ if (!environment->HasBeenRegistered()) {
+ // Physical stack frame layout:
+ // -x ............. -4 0 ..................................... y
+ // [incoming arguments] [spill slots] [pushed outgoing arguments]
+
+ // Layout of the environment:
+ // 0 ..................................................... size-1
+ // [parameters] [locals] [expression stack including arguments]
+
+ // Layout of the translation:
+ // 0 ........................................................ size - 1
+ 4
+ // [expression stack including arguments] [locals] [4 words]
[parameters]
+ // |>------------ translation_size ------------<|
+
+ int frame_count = 0;
+ for (LEnvironment* e = environment; e != NULL; e = e->outer()) {
+ ++frame_count;
+ }
+ Translation translation(&translations_, frame_count);
+ WriteTranslation(environment, &translation);
+ int deoptimization_index = deoptimizations_.length();
+ environment->Register(deoptimization_index, translation.index());
+ deoptimizations_.Add(environment);
+ }
}
@@ -859,7 +900,19 @@
void LCodeGen::EmitGoto(int block, LDeferredCode* deferred_stack_check) {
- Abort("Unimplemented: %s", "EmitGoto");
+ block = chunk_->LookupDestination(block);
+ int next_block = GetNextEmittedBlock(current_block_);
+ if (block != next_block) {
+ // Perform stack overflow check if this goto needs it before jumping.
+ if (deferred_stack_check != NULL) {
+ __ CompareRoot(rsp, Heap::kStackLimitRootIndex);
+ __ j(above_equal, chunk_->GetAssemblyLabel(block));
+ __ jmp(deferred_stack_check->entry());
+ deferred_stack_check->SetExit(chunk_->GetAssemblyLabel(block));
+ } else {
+ __ jmp(chunk_->GetAssemblyLabel(block));
+ }
+ }
}
Index: test/cctest/cctest.status
===================================================================
--- test/cctest/cctest.status (revision 6340)
+++ test/cctest/cctest.status (working copy)
@@ -77,7 +77,13 @@
# Tests that time out with crankshaft.
test-api/Threading: SKIP
+# BUG(1049): Currently no deoptimization support.
+test-serialize/ContextSerialization: SKIP
+test-serialize/ContextDeserialization: SKIP
+test-debug/BreakPointReturn: SKIP
+test-debug/DebugStepLinearMixedICs: SKIP
+
##############################################################################
[ $arch == arm ]
Index: test/mjsunit/mjsunit.status
===================================================================
--- test/mjsunit/mjsunit.status (revision 6340)
+++ test/mjsunit/mjsunit.status (working copy)
@@ -119,6 +119,9 @@
# BUG (1026) This test is currently flaky.
compiler/simple-osr: SKIP
+# BUG(1049): Currently no deoptimization support.
+debug-liveedit-newsource: SKIP
+debug-liveedit-1: SKIP
##############################################################################
[ $arch == mips ]
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev