Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Unified Diff: src/x64/macro-assembler-x64.cc

Issue 123017: X64: Create test JS-function and call it. (Closed)
Patch Set: Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/x64/codegen-x64.cc ('K') | « src/x64/codegen-x64.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/x64/macro-assembler-x64.cc
diff --git a/src/x64/macro-assembler-x64.cc b/src/x64/macro-assembler-x64.cc
index b4caa3783da258a6e90adda929c04b79160a6d2a..cb68f3a549e7606a435be36bdfc61bd3dfed6dbd 100644
--- a/src/x64/macro-assembler-x64.cc
+++ b/src/x64/macro-assembler-x64.cc
@@ -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));
+ }
}
« src/x64/codegen-x64.cc ('K') | « src/x64/codegen-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698