Commit 1ae3423a authored by whesse@chromium.org's avatar whesse@chromium.org

X64 implementation: Emit correct merge code for virtual frames at CFG merges.

Review URL: http://codereview.chromium.org/141043

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2238 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent d432b5e0
......@@ -189,7 +189,7 @@ void VirtualFrame::MakeMergable() {
backing_element = elements_[element.index()];
}
Result fresh = cgen()->allocator()->Allocate();
ASSERT(fresh.is_valid());
ASSERT(fresh.is_valid()); // A register was spilled if all were in use.
elements_[i] =
FrameElement::RegisterElement(fresh.reg(),
FrameElement::NOT_SYNCED);
......@@ -218,16 +218,15 @@ void VirtualFrame::MakeMergable() {
}
}
}
// No need to set the copied flag---there are no copies of
// copies or constants so the original was not copied.
// No need to set the copied flag---there are no copies.
// Backwards jump targets can never know the type of a value.
elements_[i].set_static_type(StaticType::unknown());
} else {
// Clear the copy flag of non-constant, non-copy elements above
// the high water mark. They cannot be copied because copes are
// always higher than their backing store and copies are not
// allowed above the water mark.
// Clear the copy flag of non-constant, non-copy elements.
// They cannot be copied because copies are not allowed.
// The copy flag is not relied on before the end of this loop,
// including when registers are spilled.
elements_[i].clear_copied();
}
}
......
......@@ -146,6 +146,16 @@ void CodeGenerator::TestCodeGenerator() {
" }"
" return x;"
" }"
"\n"
" function test_recursion_with_base(x, y, z, w) {"
" if (x) {"
" x = x;"
" } else {"
" x = test_recursion_with_base(y, z, w, 0);"
" }"
" return x;"
" }"
"\n"
" function test_local_variables(x, y){"
" var w; y = x; x = w; w = y; y = x; return w;"
" };"
......@@ -154,8 +164,9 @@ void CodeGenerator::TestCodeGenerator() {
" test_local_variables("
" test_nesting_calls(test_local_variables(1,3), 42, 47),"
" test_local_variables(-25.3, 2));"
" // return test_recursion_with_base(0, 0, 0, 47);\n"
" var o = { x: 42 };"
" return test_if_then_else(1, 47, 39);"
" return test_if_then_else(0, 46, 47);"
"})()")),
Factory::NewStringFromAscii(CStrVector("CodeGeneratorTestScript")),
0,
......
......@@ -267,6 +267,40 @@ void MacroAssembler::Set(const Operand& dst, int64_t x) {
}
bool MacroAssembler::IsUnsafeSmi(Smi* value) {
return false;
}
void MacroAssembler::LoadUnsafeSmi(Register dst, Smi* source) {
UNIMPLEMENTED();
}
void MacroAssembler::Move(Register dst, Handle<Object> source) {
if (source->IsSmi()) {
if (IsUnsafeSmi(source)) {
LoadUnsafeSmi(dst, source);
} else {
movq(dst, source, RelocInfo::NONE);
}
} else {
movq(dst, source, RelocInfo::EMBEDDED_OBJECT);
}
}
void MacroAssembler::Move(const Operand& dst, Handle<Object> source) {
Move(kScratchRegister, source);
movq(dst, kScratchRegister);
}
void MacroAssembler::Cmp(Register dst, Handle<Object> source) {
Move(kScratchRegister, source);
cmpq(dst, kScratchRegister);
}
void MacroAssembler::Jump(ExternalReference ext) {
movq(kScratchRegister, ext);
jmp(kScratchRegister);
......
......@@ -158,6 +158,21 @@ class MacroAssembler: public Assembler {
void Set(Register dst, int64_t x);
void Set(const Operand& dst, int64_t x);
// Handle support
bool IsUnsafeSmi(Smi* value);
bool IsUnsafeSmi(Handle<Object> value) {
return IsUnsafeSmi(Smi::cast(*value));
}
void LoadUnsafeSmi(Register dst, Smi* source);
void LoadUnsafeSmi(Register dst, Handle<Object> source) {
LoadUnsafeSmi(dst, Smi::cast(*source));
}
void Move(Register dst, Handle<Object> source);
void Move(const Operand& dst, Handle<Object> source);
void Cmp(Register dst, Handle<Object> source);
// Control Flow
void Jump(Address destination, RelocInfo::Mode rmode);
void Jump(ExternalReference ext);
......
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