Commit d39df380 authored by lrn@chromium.org's avatar lrn@chromium.org

X64: Create test JS-function and call it.

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


git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2145 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent a8507cb4
......@@ -251,7 +251,7 @@ Object** RelocInfo::call_object_address() {
void Operand::set_modrm(int mod, Register rm) {
ASSERT((mod & -4) == 0);
buf_[0] = mod << 6 | (rm.code() & 0x7);
buf_[0] = (mod << 6) | (rm.code() & 0x7);
// Set REX.B to the high bit of rm.code().
rex_ |= (rm.code() >> 3);
}
......
......@@ -81,7 +81,7 @@ Operand::Operand(Register base, int32_t disp): rex_(0) {
}
if (disp == 0 && !base.is(rbp) && !base.is(r13)) {
set_modrm(0, rsp);
set_modrm(0, base);
} else if (is_int8(disp)) {
set_modrm(1, base);
set_disp8(disp);
......
......@@ -571,7 +571,8 @@ void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) {
ExternalReference entry(Builtins::JSEntryTrampoline);
__ load_rax(entry);
}
__ call(FieldOperand(rax, Code::kHeaderSize));
__ lea(kScratchRegister, FieldOperand(rax, Code::kHeaderSize));
__ call(kScratchRegister);
// Unlink this frame from the handler chain.
__ movq(kScratchRegister, ExternalReference(Top::k_handler_address));
......
......@@ -63,14 +63,38 @@ void MacroAssembler::ConstructAndTestJSFunction() {
const int initial_buffer_size = 4 * KB;
char* buffer = new char[initial_buffer_size];
MacroAssembler masm(buffer, initial_buffer_size);
const uint64_t secret = V8_INT64_C(0xdeadbeefcafebabe);
#define __ ACCESS_MASM((&masm))
// Construct a simple JSfunction here, using Assembler and MacroAssembler
// commands.
__ int3();
__ movq(rax, secret, RelocInfo::NONE);
__ ret(0);
#undef __
CodeDesc desc;
masm.GetCode(&desc);
// TODO(X64): Create the function object and call it.
Code::Flags flags = Code::ComputeFlags(Code::FUNCTION);
Object* code = Heap::CreateCode(desc, NULL, flags, Handle<Object>::null());
if (!code->IsFailure()) {
Handle<Code> code_handle(Code::cast(code));
Handle<String> name =
Factory::NewStringFromAscii(Vector<const char>("foo", 3), NOT_TENURED);
Handle<JSFunction> function =
Factory::NewFunction(name,
JS_FUNCTION_TYPE,
JSObject::kHeaderSize,
code_handle,
true);
bool pending_exceptions;
Handle<Object> result =
Execution::Call(function,
Handle<Object>::cast(function),
0,
NULL,
&pending_exceptions);
CHECK(result->IsSmi());
CHECK(secret == reinterpret_cast<uint64_t>(*result));
}
}
......
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