| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 | 49 |
| 50 #define __ assm. | 50 #define __ assm. |
| 51 | 51 |
| 52 | 52 |
| 53 static void DummyStaticFunction(Object* result) { | 53 static void DummyStaticFunction(Object* result) { |
| 54 } | 54 } |
| 55 | 55 |
| 56 | 56 |
| 57 TEST(DisasmIa320) { | 57 TEST(DisasmIa320) { |
| 58 InitializeVM(); | 58 InitializeVM(); |
| 59 v8::HandleScope scope; | 59 Isolate* isolate = reinterpret_cast<Isolate*>(env->GetIsolate()); |
| 60 HandleScope scope(isolate); |
| 60 v8::internal::byte buffer[2048]; | 61 v8::internal::byte buffer[2048]; |
| 61 Assembler assm(Isolate::Current(), buffer, sizeof buffer); | 62 Assembler assm(isolate, buffer, sizeof buffer); |
| 62 DummyStaticFunction(NULL); // just bloody use it (DELETE; debugging) | 63 DummyStaticFunction(NULL); // just bloody use it (DELETE; debugging) |
| 63 | 64 |
| 64 // Short immediate instructions | 65 // Short immediate instructions |
| 65 __ adc(eax, 12345678); | 66 __ adc(eax, 12345678); |
| 66 __ add(eax, Immediate(12345678)); | 67 __ add(eax, Immediate(12345678)); |
| 67 __ or_(eax, 12345678); | 68 __ or_(eax, 12345678); |
| 68 __ sub(eax, Immediate(12345678)); | 69 __ sub(eax, Immediate(12345678)); |
| 69 __ xor_(eax, 12345678); | 70 __ xor_(eax, 12345678); |
| 70 __ and_(eax, 12345678); | 71 __ and_(eax, 12345678); |
| 71 Handle<FixedArray> foo = FACTORY->NewFixedArray(10, TENURED); | 72 Handle<FixedArray> foo = FACTORY->NewFixedArray(10, TENURED); |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 | 264 |
| 264 Label L1, L2; | 265 Label L1, L2; |
| 265 __ bind(&L1); | 266 __ bind(&L1); |
| 266 __ nop(); | 267 __ nop(); |
| 267 __ call(&L1); | 268 __ call(&L1); |
| 268 __ call(&L2); | 269 __ call(&L2); |
| 269 __ nop(); | 270 __ nop(); |
| 270 __ bind(&L2); | 271 __ bind(&L2); |
| 271 __ call(Operand(ebx, ecx, times_4, 10000)); | 272 __ call(Operand(ebx, ecx, times_4, 10000)); |
| 272 __ nop(); | 273 __ nop(); |
| 273 Handle<Code> ic(Isolate::Current()->builtins()->builtin( | 274 Handle<Code> ic(isolate->builtins()->builtin(Builtins::kLoadIC_Initialize)); |
| 274 Builtins::kLoadIC_Initialize)); | |
| 275 __ call(ic, RelocInfo::CODE_TARGET); | 275 __ call(ic, RelocInfo::CODE_TARGET); |
| 276 __ nop(); | 276 __ nop(); |
| 277 __ call(FUNCTION_ADDR(DummyStaticFunction), RelocInfo::RUNTIME_ENTRY); | 277 __ call(FUNCTION_ADDR(DummyStaticFunction), RelocInfo::RUNTIME_ENTRY); |
| 278 __ nop(); | 278 __ nop(); |
| 279 | 279 |
| 280 __ jmp(&L1); | 280 __ jmp(&L1); |
| 281 __ jmp(Operand(ebx, ecx, times_4, 10000)); | 281 __ jmp(Operand(ebx, ecx, times_4, 10000)); |
| 282 #ifdef ENABLE_DEBUGGER_SUPPORT | 282 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 283 ExternalReference after_break_target = | 283 ExternalReference after_break_target = |
| 284 ExternalReference(Debug_Address::AfterBreakTarget(), | 284 ExternalReference(Debug_Address::AfterBreakTarget(), isolate); |
| 285 assm.isolate()); | |
| 286 __ jmp(Operand::StaticVariable(after_break_target)); | 285 __ jmp(Operand::StaticVariable(after_break_target)); |
| 287 #endif // ENABLE_DEBUGGER_SUPPORT | 286 #endif // ENABLE_DEBUGGER_SUPPORT |
| 288 __ jmp(ic, RelocInfo::CODE_TARGET); | 287 __ jmp(ic, RelocInfo::CODE_TARGET); |
| 289 __ nop(); | 288 __ nop(); |
| 290 | 289 |
| 291 | 290 |
| 292 Label Ljcc; | 291 Label Ljcc; |
| 293 __ nop(); | 292 __ nop(); |
| 294 // long jumps | 293 // long jumps |
| 295 __ j(overflow, &Ljcc); | 294 __ j(overflow, &Ljcc); |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 | 451 |
| 453 // Nop instructions | 452 // Nop instructions |
| 454 for (int i = 0; i < 16; i++) { | 453 for (int i = 0; i < 16; i++) { |
| 455 __ Nop(i); | 454 __ Nop(i); |
| 456 } | 455 } |
| 457 | 456 |
| 458 __ ret(0); | 457 __ ret(0); |
| 459 | 458 |
| 460 CodeDesc desc; | 459 CodeDesc desc; |
| 461 assm.GetCode(&desc); | 460 assm.GetCode(&desc); |
| 462 Isolate* isolate = Isolate::Current(); | |
| 463 Object* code = isolate->heap()->CreateCode( | 461 Object* code = isolate->heap()->CreateCode( |
| 464 desc, | 462 desc, |
| 465 Code::ComputeFlags(Code::STUB), | 463 Code::ComputeFlags(Code::STUB), |
| 466 Handle<Code>())->ToObjectChecked(); | 464 Handle<Code>())->ToObjectChecked(); |
| 467 CHECK(code->IsCode()); | 465 CHECK(code->IsCode()); |
| 468 #ifdef OBJECT_PRINT | 466 #ifdef OBJECT_PRINT |
| 469 Code::cast(code)->Print(); | 467 Code::cast(code)->Print(); |
| 470 byte* begin = Code::cast(code)->instruction_start(); | 468 byte* begin = Code::cast(code)->instruction_start(); |
| 471 byte* end = begin + Code::cast(code)->instruction_size(); | 469 byte* end = begin + Code::cast(code)->instruction_size(); |
| 472 disasm::Disassembler::Disassemble(stdout, begin, end); | 470 disasm::Disassembler::Disassemble(stdout, begin, end); |
| 473 #endif | 471 #endif |
| 474 } | 472 } |
| 475 | 473 |
| 476 #undef __ | 474 #undef __ |
| OLD | NEW |