42 using v8::internal::Immediate;
44 using v8::internal::Label;
46 using v8::internal::Operand;
77 typedef int (*
F1)(int64_t x);
78 typedef int (*
F2)(int64_t x, int64_t y);
94 static void InitializeVM() {
101 TEST(AssemblerX64ReturnOperation) {
105 byte* buffer =
static_cast<byte*
>(OS::Allocate(Assembler::kMinimalBufferSize,
109 Assembler assm(Isolate::Current(), buffer, static_cast<int>(actual_size));
119 int result = FUNCTION_CAST<F2>(buffer)(3, 2);
123 TEST(AssemblerX64StackOperations) {
127 byte* buffer =
static_cast<byte*
>(OS::Allocate(Assembler::kMinimalBufferSize,
131 Assembler assm(Isolate::Current(), buffer, static_cast<int>(actual_size));
151 int result = FUNCTION_CAST<F2>(buffer)(3, 2);
155 TEST(AssemblerX64ArithmeticOperations) {
159 byte* buffer =
static_cast<byte*
>(OS::Allocate(Assembler::kMinimalBufferSize,
163 Assembler assm(Isolate::Current(), buffer, static_cast<int>(actual_size));
173 int result = FUNCTION_CAST<F2>(buffer)(3, 2);
177 TEST(AssemblerX64ImulOperation) {
181 byte* buffer =
static_cast<byte*
>(OS::Allocate(Assembler::kMinimalBufferSize,
185 Assembler assm(Isolate::Current(), buffer, static_cast<int>(actual_size));
197 int result = FUNCTION_CAST<F2>(buffer)(3, 2);
199 result = FUNCTION_CAST<F2>(buffer)(0x100000000l, 0x100000000l);
201 result = FUNCTION_CAST<F2>(buffer)(-0x100000000l, 0x100000000l);
205 TEST(AssemblerX64MemoryOperands) {
209 byte* buffer =
static_cast<byte*
>(OS::Allocate(Assembler::kMinimalBufferSize,
213 Assembler assm(Isolate::Current(), buffer, static_cast<int>(actual_size));
223 const int kStackElementSize = 8;
224 __ movq(
rax, Operand(
rbp, -3 * kStackElementSize));
235 int result = FUNCTION_CAST<F2>(buffer)(3, 2);
239 TEST(AssemblerX64ControlFlow) {
243 byte* buffer =
static_cast<byte*
>(OS::Allocate(Assembler::kMinimalBufferSize,
247 Assembler assm(Isolate::Current(), buffer, static_cast<int>(actual_size));
264 int result = FUNCTION_CAST<F2>(buffer)(3, 2);
268 TEST(AssemblerX64LoopImmediates) {
272 byte* buffer =
static_cast<byte*
>(OS::Allocate(Assembler::kMinimalBufferSize,
276 Assembler assm(Isolate::Current(), buffer, static_cast<int>(actual_size));
279 __ movq(
rax, Immediate(-3));
283 __ bind(&Loop1_body);
284 __ addq(
rax, Immediate(7));
285 __ bind(&Loop1_test);
286 __ cmpq(
rax, Immediate(20));
289 __ cmpq(
rax, Immediate(25));
294 __ movq(
rax, Immediate(0x11FEED00));
296 __ bind(&Loop2_body);
297 __ addq(
rax, Immediate(-0x1100));
298 __ bind(&Loop2_test);
299 __ cmpq(
rax, Immediate(0x11FE8000));
302 __ cmpq(
rax, Immediate(0x11FE7600));
305 __ movq(
rax, Immediate(1));
308 __ movq(
rax, Immediate(0));
314 int result = FUNCTION_CAST<F0>(buffer)();
319 TEST(OperandRegisterDependency) {
320 int offsets[4] = {0, 1, 0xfed, 0xbeefcad};
321 for (
int i = 0; i < 4; i++) {
322 int offset = offsets[i];
323 CHECK(Operand(
rax, offset).AddressUsesRegister(
rax));
324 CHECK(!Operand(
rax, offset).AddressUsesRegister(
r8));
325 CHECK(!Operand(
rax, offset).AddressUsesRegister(
rcx));
338 CHECK(Operand(
rsp, offset).AddressUsesRegister(
rsp));
339 CHECK(!Operand(
rsp, offset).AddressUsesRegister(
rax));
340 CHECK(!Operand(
rsp, offset).AddressUsesRegister(
r15));
342 CHECK(Operand(
rbp, offset).AddressUsesRegister(
rbp));
343 CHECK(!Operand(
rbp, offset).AddressUsesRegister(
rax));
344 CHECK(!Operand(
rbp, offset).AddressUsesRegister(
r13));
362 TEST(AssemblerX64LabelChaining) {
379 Assembler assm(Isolate::Current(), buffer,
sizeof(buffer));
385 __ movq(
rax, Immediate(1));
386 __ movq(
rbx, Immediate(2));
387 __ movq(
rcx, Immediate(3));
388 __ movq(
rdx, Immediate(4));
389 __ movq(
rdi, Immediate(5));
390 __ movq(
rsi, Immediate(6));
391 for (
int i = 0; i < 16; i++) {
398 __ cmpq(
rax, Immediate(1));
400 __ cmpq(
rbx, Immediate(2));
402 __ cmpq(
rcx, Immediate(3));
404 __ cmpq(
rdx, Immediate(4));
406 __ cmpq(
rdi, Immediate(5));
408 __ cmpq(
rsi, Immediate(6));
410 __ movq(
rax, Immediate(42));
418 __ movq(
rax, Immediate(13));
428 Code* code = Code::cast(
HEAP->CreateCode(
430 Code::ComputeFlags(Code::STUB),
432 HEAP->undefined_value()))->ToObjectChecked());
433 CHECK(code->IsCode());
435 F0 f = FUNCTION_CAST<F0>(code->
entry());
#define CHECK_EQ(expected, value)
v8::Handle< v8::Value > Fail(const v8::Arguments &args)
TEST(AssemblerX64ReturnOperation)
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination trace on stack replacement optimize closures functions with arguments object optimize functions containing for in loops profiler considers IC stability primitive functions trigger their own optimization re try self optimization if it failed insert an interrupt check at function exit execution budget before interrupt is triggered call count before self optimization self_optimization count_based_interrupts weighted_back_edges trace_opt emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 enable use of ARMv7 instructions if enable use of MIPS FPU instructions if NULL
void GetCode(CodeDesc *desc)
int(* F2)(int64_t x, int64_t y)
static Persistent< Context > New(ExtensionConfiguration *extensions=NULL, Handle< ObjectTemplate > global_template=Handle< ObjectTemplate >(), Handle< Value > global_object=Handle< Value >())
F FUNCTION_CAST(Address addr)