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

Side by Side Diff: test/cctest/test-assembler-x64.cc

Issue 8773039: Clean up multi byte nop support on x64 to more closely match IA32. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 9 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/cctest/SConscript ('k') | test/cctest/test-disasm-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 18 matching lines...) Expand all
29 29
30 #include "v8.h" 30 #include "v8.h"
31 31
32 #include "macro-assembler.h" 32 #include "macro-assembler.h"
33 #include "factory.h" 33 #include "factory.h"
34 #include "platform.h" 34 #include "platform.h"
35 #include "serialize.h" 35 #include "serialize.h"
36 #include "cctest.h" 36 #include "cctest.h"
37 37
38 using v8::internal::Assembler; 38 using v8::internal::Assembler;
39 using v8::internal::Code;
39 using v8::internal::CodeDesc; 40 using v8::internal::CodeDesc;
40 using v8::internal::FUNCTION_CAST; 41 using v8::internal::FUNCTION_CAST;
41 using v8::internal::Immediate; 42 using v8::internal::Immediate;
42 using v8::internal::Isolate; 43 using v8::internal::Isolate;
43 using v8::internal::Label; 44 using v8::internal::Label;
44 using v8::internal::OS; 45 using v8::internal::OS;
45 using v8::internal::Operand; 46 using v8::internal::Operand;
46 using v8::internal::byte; 47 using v8::internal::byte;
47 using v8::internal::greater; 48 using v8::internal::greater;
48 using v8::internal::less_equal; 49 using v8::internal::less_equal;
49 using v8::internal::equal; 50 using v8::internal::equal;
50 using v8::internal::not_equal; 51 using v8::internal::not_equal;
51 using v8::internal::r13; 52 using v8::internal::r13;
52 using v8::internal::r15; 53 using v8::internal::r15;
53 using v8::internal::r8; 54 using v8::internal::r8;
54 using v8::internal::r9; 55 using v8::internal::r9;
55 using v8::internal::rax; 56 using v8::internal::rax;
57 using v8::internal::rbx;
56 using v8::internal::rbp; 58 using v8::internal::rbp;
57 using v8::internal::rcx; 59 using v8::internal::rcx;
58 using v8::internal::rdi; 60 using v8::internal::rdi;
59 using v8::internal::rdx; 61 using v8::internal::rdx;
60 using v8::internal::rsi; 62 using v8::internal::rsi;
61 using v8::internal::rsp; 63 using v8::internal::rsp;
62 using v8::internal::times_1; 64 using v8::internal::times_1;
63 65
64 // Test the x64 assembler by compiling some simple functions into 66 // Test the x64 assembler by compiling some simple functions into
65 // a buffer and executing them. These tests do not initialize the 67 // a buffer and executing them. These tests do not initialize the
(...skipping 13 matching lines...) Expand all
79 static const v8::internal::Register arg1 = rcx; 81 static const v8::internal::Register arg1 = rcx;
80 static const v8::internal::Register arg2 = rdx; 82 static const v8::internal::Register arg2 = rdx;
81 #else 83 #else
82 static const v8::internal::Register arg1 = rdi; 84 static const v8::internal::Register arg1 = rdi;
83 static const v8::internal::Register arg2 = rsi; 85 static const v8::internal::Register arg2 = rsi;
84 #endif 86 #endif
85 87
86 #define __ assm. 88 #define __ assm.
87 89
88 90
91 static v8::Persistent<v8::Context> env;
92
93
94 static void InitializeVM() {
95 if (env.IsEmpty()) {
96 env = v8::Context::New();
97 }
98 }
99
100
89 TEST(AssemblerX64ReturnOperation) { 101 TEST(AssemblerX64ReturnOperation) {
90 OS::Setup(); 102 OS::Setup();
91 // Allocate an executable page of memory. 103 // Allocate an executable page of memory.
92 size_t actual_size; 104 size_t actual_size;
93 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, 105 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize,
94 &actual_size, 106 &actual_size,
95 true)); 107 true));
96 CHECK(buffer); 108 CHECK(buffer);
97 Assembler assm(Isolate::Current(), buffer, static_cast<int>(actual_size)); 109 Assembler assm(Isolate::Current(), buffer, static_cast<int>(actual_size));
98 110
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 v8::HandleScope scope; 364 v8::HandleScope scope;
353 Assembler assm(Isolate::Current(), NULL, 0); 365 Assembler assm(Isolate::Current(), NULL, 0);
354 366
355 Label target; 367 Label target;
356 __ j(equal, &target); 368 __ j(equal, &target);
357 __ j(not_equal, &target); 369 __ j(not_equal, &target);
358 __ bind(&target); 370 __ bind(&target);
359 __ nop(); 371 __ nop();
360 } 372 }
361 373
374
375 TEST(AssemblerMultiByteNop) {
376 InitializeVM();
377 v8::HandleScope scope;
378 v8::internal::byte buffer[1024];
379 Assembler assm(Isolate::Current(), buffer, sizeof(buffer));
380 __ push(rbx);
381 __ push(rcx);
382 __ push(rdx);
383 __ push(rdi);
384 __ push(rsi);
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++) {
392 int before = assm.pc_offset();
393 __ Nop(i);
394 CHECK_EQ(assm.pc_offset() - before, i);
395 }
396
397 Label fail;
398 __ cmpq(rax, Immediate(1));
399 __ j(not_equal, &fail);
400 __ cmpq(rbx, Immediate(2));
401 __ j(not_equal, &fail);
402 __ cmpq(rcx, Immediate(3));
403 __ j(not_equal, &fail);
404 __ cmpq(rdx, Immediate(4));
405 __ j(not_equal, &fail);
406 __ cmpq(rdi, Immediate(5));
407 __ j(not_equal, &fail);
408 __ cmpq(rsi, Immediate(6));
409 __ j(not_equal, &fail);
410 __ movq(rax, Immediate(42));
411 __ pop(rsi);
412 __ pop(rdi);
413 __ pop(rdx);
414 __ pop(rcx);
415 __ pop(rbx);
416 __ ret(0);
417 __ bind(&fail);
418 __ movq(rax, Immediate(13));
419 __ pop(rsi);
420 __ pop(rdi);
421 __ pop(rdx);
422 __ pop(rcx);
423 __ pop(rbx);
424 __ ret(0);
425
426 CodeDesc desc;
427 assm.GetCode(&desc);
428 Code* code = Code::cast(HEAP->CreateCode(
429 desc,
430 Code::ComputeFlags(Code::STUB),
431 v8::internal::Handle<v8::internal::Object>(
432 HEAP->undefined_value()))->ToObjectChecked());
433 CHECK(code->IsCode());
434
435 F0 f = FUNCTION_CAST<F0>(code->entry());
436 int res = f();
437 CHECK_EQ(42, res);
438 }
439
440
441
442
362 #undef __ 443 #undef __
OLDNEW
« no previous file with comments | « test/cctest/SConscript ('k') | test/cctest/test-disasm-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698