| OLD | NEW |
| 1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2008 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 Assembler assm(buffer, sizeof buffer); | 61 Assembler assm(buffer, sizeof buffer); |
| 62 DummyStaticFunction(NULL); // just bloody use it (DELETE; debugging) | 62 DummyStaticFunction(NULL); // just bloody use it (DELETE; debugging) |
| 63 | 63 |
| 64 // Short immediate instructions | 64 // Short immediate instructions |
| 65 __ adc(eax, 12345678); | 65 __ adc(eax, 12345678); |
| 66 __ add(Operand(eax), Immediate(12345678)); | 66 __ add(Operand(eax), Immediate(12345678)); |
| 67 __ or_(eax, 12345678); | 67 __ or_(eax, 12345678); |
| 68 __ sub(Operand(eax), Immediate(12345678)); | 68 __ sub(Operand(eax), Immediate(12345678)); |
| 69 __ xor_(eax, 12345678); | 69 __ xor_(eax, 12345678); |
| 70 __ and_(eax, 12345678); | 70 __ and_(eax, 12345678); |
| 71 Handle<FixedArray> foo = Factory::NewFixedArray(10, TENURED); | 71 Handle<FixedArray> foo = FACTORY->NewFixedArray(10, TENURED); |
| 72 __ cmp(eax, foo); | 72 __ cmp(eax, foo); |
| 73 | 73 |
| 74 // ---- This one caused crash | 74 // ---- This one caused crash |
| 75 __ mov(ebx, Operand(esp, ecx, times_2, 0)); // [esp+ecx*4] | 75 __ mov(ebx, Operand(esp, ecx, times_2, 0)); // [esp+ecx*4] |
| 76 | 76 |
| 77 // ---- All instructions that I can think of | 77 // ---- All instructions that I can think of |
| 78 __ add(edx, Operand(ebx)); | 78 __ add(edx, Operand(ebx)); |
| 79 __ add(edx, Operand(12, RelocInfo::NONE)); | 79 __ add(edx, Operand(12, RelocInfo::NONE)); |
| 80 __ add(edx, Operand(ebx, 0)); | 80 __ add(edx, Operand(ebx, 0)); |
| 81 __ add(edx, Operand(ebx, 16)); | 81 __ add(edx, Operand(ebx, 16)); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 92 __ add(Operand(ebx), Immediate(12)); | 92 __ add(Operand(ebx), Immediate(12)); |
| 93 __ nop(); | 93 __ nop(); |
| 94 __ adc(ecx, 12); | 94 __ adc(ecx, 12); |
| 95 __ adc(ecx, 1000); | 95 __ adc(ecx, 1000); |
| 96 __ nop(); | 96 __ nop(); |
| 97 __ and_(edx, 3); | 97 __ and_(edx, 3); |
| 98 __ and_(edx, Operand(esp, 4)); | 98 __ and_(edx, Operand(esp, 4)); |
| 99 __ cmp(edx, 3); | 99 __ cmp(edx, 3); |
| 100 __ cmp(edx, Operand(esp, 4)); | 100 __ cmp(edx, Operand(esp, 4)); |
| 101 __ cmp(Operand(ebp, ecx, times_4, 0), Immediate(1000)); | 101 __ cmp(Operand(ebp, ecx, times_4, 0), Immediate(1000)); |
| 102 Handle<FixedArray> foo2 = Factory::NewFixedArray(10, TENURED); | 102 Handle<FixedArray> foo2 = FACTORY->NewFixedArray(10, TENURED); |
| 103 __ cmp(ebx, foo2); | 103 __ cmp(ebx, foo2); |
| 104 __ cmpb(ebx, Operand(ebp, ecx, times_2, 0)); | 104 __ cmpb(ebx, Operand(ebp, ecx, times_2, 0)); |
| 105 __ cmpb(Operand(ebp, ecx, times_2, 0), ebx); | 105 __ cmpb(Operand(ebp, ecx, times_2, 0), ebx); |
| 106 __ or_(edx, 3); | 106 __ or_(edx, 3); |
| 107 __ xor_(edx, 3); | 107 __ xor_(edx, 3); |
| 108 __ nop(); | 108 __ nop(); |
| 109 { | 109 { |
| 110 CHECK(CpuFeatures::IsSupported(CPUID)); | 110 CHECK(Isolate::Current()->cpu_features()->IsSupported(CPUID)); |
| 111 CpuFeatures::Scope fscope(CPUID); | 111 CpuFeatures::Scope fscope(CPUID); |
| 112 __ cpuid(); | 112 __ cpuid(); |
| 113 } | 113 } |
| 114 { | 114 { |
| 115 CHECK(CpuFeatures::IsSupported(RDTSC)); | 115 CHECK(Isolate::Current()->cpu_features()->IsSupported(RDTSC)); |
| 116 CpuFeatures::Scope fscope(RDTSC); | 116 CpuFeatures::Scope fscope(RDTSC); |
| 117 __ rdtsc(); | 117 __ rdtsc(); |
| 118 } | 118 } |
| 119 __ movsx_b(edx, Operand(ecx)); | 119 __ movsx_b(edx, Operand(ecx)); |
| 120 __ movsx_w(edx, Operand(ecx)); | 120 __ movsx_w(edx, Operand(ecx)); |
| 121 __ movzx_b(edx, Operand(ecx)); | 121 __ movzx_b(edx, Operand(ecx)); |
| 122 __ movzx_w(edx, Operand(ecx)); | 122 __ movzx_w(edx, Operand(ecx)); |
| 123 | 123 |
| 124 __ nop(); | 124 __ nop(); |
| 125 __ imul(edx, Operand(ecx)); | 125 __ imul(edx, Operand(ecx)); |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 | 265 |
| 266 Label L1, L2; | 266 Label L1, L2; |
| 267 __ bind(&L1); | 267 __ bind(&L1); |
| 268 __ nop(); | 268 __ nop(); |
| 269 __ call(&L1); | 269 __ call(&L1); |
| 270 __ call(&L2); | 270 __ call(&L2); |
| 271 __ nop(); | 271 __ nop(); |
| 272 __ bind(&L2); | 272 __ bind(&L2); |
| 273 __ call(Operand(ebx, ecx, times_4, 10000)); | 273 __ call(Operand(ebx, ecx, times_4, 10000)); |
| 274 __ nop(); | 274 __ nop(); |
| 275 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize)); | 275 Handle<Code> ic(Isolate::Current()->builtins()->builtin( |
| 276 Builtins::LoadIC_Initialize)); |
| 276 __ call(ic, RelocInfo::CODE_TARGET); | 277 __ call(ic, RelocInfo::CODE_TARGET); |
| 277 __ nop(); | 278 __ nop(); |
| 278 __ call(FUNCTION_ADDR(DummyStaticFunction), RelocInfo::RUNTIME_ENTRY); | 279 __ call(FUNCTION_ADDR(DummyStaticFunction), RelocInfo::RUNTIME_ENTRY); |
| 279 __ nop(); | 280 __ nop(); |
| 280 | 281 |
| 281 __ jmp(&L1); | 282 __ jmp(&L1); |
| 282 __ jmp(Operand(ebx, ecx, times_4, 10000)); | 283 __ jmp(Operand(ebx, ecx, times_4, 10000)); |
| 283 #ifdef ENABLE_DEBUGGER_SUPPORT | 284 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 284 ExternalReference after_break_target = | 285 ExternalReference after_break_target = |
| 285 ExternalReference(Debug_Address::AfterBreakTarget()); | 286 ExternalReference(Debug_Address::AfterBreakTarget()); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 __ j(parity_odd, &Ljcc); | 326 __ j(parity_odd, &Ljcc); |
| 326 __ j(less, &Ljcc); | 327 __ j(less, &Ljcc); |
| 327 __ j(greater_equal, &Ljcc); | 328 __ j(greater_equal, &Ljcc); |
| 328 __ j(less_equal, &Ljcc); | 329 __ j(less_equal, &Ljcc); |
| 329 __ j(greater, &Ljcc); | 330 __ j(greater, &Ljcc); |
| 330 | 331 |
| 331 // checking hints | 332 // checking hints |
| 332 __ j(zero, &Ljcc, taken); | 333 __ j(zero, &Ljcc, taken); |
| 333 __ j(zero, &Ljcc, not_taken); | 334 __ j(zero, &Ljcc, not_taken); |
| 334 | 335 |
| 335 // __ mov(Operand::StaticVariable(Top::handler_address()), eax); | 336 // __ mov(Operand::StaticVariable(Isolate::handler_address()), eax); |
| 336 // 0xD9 instructions | 337 // 0xD9 instructions |
| 337 __ nop(); | 338 __ nop(); |
| 338 | 339 |
| 339 __ fld(1); | 340 __ fld(1); |
| 340 __ fld1(); | 341 __ fld1(); |
| 341 __ fldz(); | 342 __ fldz(); |
| 342 __ fldpi(); | 343 __ fldpi(); |
| 343 __ fabs(); | 344 __ fabs(); |
| 344 __ fchs(); | 345 __ fchs(); |
| 345 __ fprem(); | 346 __ fprem(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 366 __ fdiv(3); | 367 __ fdiv(3); |
| 367 | 368 |
| 368 __ faddp(3); | 369 __ faddp(3); |
| 369 __ fsubp(3); | 370 __ fsubp(3); |
| 370 __ fmulp(3); | 371 __ fmulp(3); |
| 371 __ fdivp(3); | 372 __ fdivp(3); |
| 372 __ fcompp(); | 373 __ fcompp(); |
| 373 __ fwait(); | 374 __ fwait(); |
| 374 __ nop(); | 375 __ nop(); |
| 375 { | 376 { |
| 376 if (CpuFeatures::IsSupported(SSE2)) { | 377 if (Isolate::Current()->cpu_features()->IsSupported(SSE2)) { |
| 377 CpuFeatures::Scope fscope(SSE2); | 378 CpuFeatures::Scope fscope(SSE2); |
| 378 __ cvttss2si(edx, Operand(ebx, ecx, times_4, 10000)); | 379 __ cvttss2si(edx, Operand(ebx, ecx, times_4, 10000)); |
| 379 __ cvtsi2sd(xmm1, Operand(ebx, ecx, times_4, 10000)); | 380 __ cvtsi2sd(xmm1, Operand(ebx, ecx, times_4, 10000)); |
| 380 __ addsd(xmm1, xmm0); | 381 __ addsd(xmm1, xmm0); |
| 381 __ mulsd(xmm1, xmm0); | 382 __ mulsd(xmm1, xmm0); |
| 382 __ subsd(xmm1, xmm0); | 383 __ subsd(xmm1, xmm0); |
| 383 __ divsd(xmm1, xmm0); | 384 __ divsd(xmm1, xmm0); |
| 384 __ movdbl(xmm1, Operand(ebx, ecx, times_4, 10000)); | 385 __ movdbl(xmm1, Operand(ebx, ecx, times_4, 10000)); |
| 385 __ movdbl(Operand(ebx, ecx, times_4, 10000), xmm1); | 386 __ movdbl(Operand(ebx, ecx, times_4, 10000), xmm1); |
| 386 __ ucomisd(xmm0, xmm1); | 387 __ ucomisd(xmm0, xmm1); |
| 387 | 388 |
| 388 // 128 bit move instructions. | 389 // 128 bit move instructions. |
| 389 __ movdqa(xmm0, Operand(ebx, ecx, times_4, 10000)); | 390 __ movdqa(xmm0, Operand(ebx, ecx, times_4, 10000)); |
| 390 __ movdqa(Operand(ebx, ecx, times_4, 10000), xmm0); | 391 __ movdqa(Operand(ebx, ecx, times_4, 10000), xmm0); |
| 391 __ movdqu(xmm0, Operand(ebx, ecx, times_4, 10000)); | 392 __ movdqu(xmm0, Operand(ebx, ecx, times_4, 10000)); |
| 392 __ movdqu(Operand(ebx, ecx, times_4, 10000), xmm0); | 393 __ movdqu(Operand(ebx, ecx, times_4, 10000), xmm0); |
| 393 } | 394 } |
| 394 } | 395 } |
| 395 | 396 |
| 396 // cmov. | 397 // cmov. |
| 397 { | 398 { |
| 398 if (CpuFeatures::IsSupported(CMOV)) { | 399 if (Isolate::Current()->cpu_features()->IsSupported(CMOV)) { |
| 399 CpuFeatures::Scope use_cmov(CMOV); | 400 CpuFeatures::Scope use_cmov(CMOV); |
| 400 __ cmov(overflow, eax, Operand(eax, 0)); | 401 __ cmov(overflow, eax, Operand(eax, 0)); |
| 401 __ cmov(no_overflow, eax, Operand(eax, 1)); | 402 __ cmov(no_overflow, eax, Operand(eax, 1)); |
| 402 __ cmov(below, eax, Operand(eax, 2)); | 403 __ cmov(below, eax, Operand(eax, 2)); |
| 403 __ cmov(above_equal, eax, Operand(eax, 3)); | 404 __ cmov(above_equal, eax, Operand(eax, 3)); |
| 404 __ cmov(equal, eax, Operand(ebx, 0)); | 405 __ cmov(equal, eax, Operand(ebx, 0)); |
| 405 __ cmov(not_equal, eax, Operand(ebx, 1)); | 406 __ cmov(not_equal, eax, Operand(ebx, 1)); |
| 406 __ cmov(below_equal, eax, Operand(ebx, 2)); | 407 __ cmov(below_equal, eax, Operand(ebx, 2)); |
| 407 __ cmov(above, eax, Operand(ebx, 3)); | 408 __ cmov(above, eax, Operand(ebx, 3)); |
| 408 __ cmov(sign, eax, Operand(ecx, 0)); | 409 __ cmov(sign, eax, Operand(ecx, 0)); |
| 409 __ cmov(not_sign, eax, Operand(ecx, 1)); | 410 __ cmov(not_sign, eax, Operand(ecx, 1)); |
| 410 __ cmov(parity_even, eax, Operand(ecx, 2)); | 411 __ cmov(parity_even, eax, Operand(ecx, 2)); |
| 411 __ cmov(parity_odd, eax, Operand(ecx, 3)); | 412 __ cmov(parity_odd, eax, Operand(ecx, 3)); |
| 412 __ cmov(less, eax, Operand(edx, 0)); | 413 __ cmov(less, eax, Operand(edx, 0)); |
| 413 __ cmov(greater_equal, eax, Operand(edx, 1)); | 414 __ cmov(greater_equal, eax, Operand(edx, 1)); |
| 414 __ cmov(less_equal, eax, Operand(edx, 2)); | 415 __ cmov(less_equal, eax, Operand(edx, 2)); |
| 415 __ cmov(greater, eax, Operand(edx, 3)); | 416 __ cmov(greater, eax, Operand(edx, 3)); |
| 416 } | 417 } |
| 417 } | 418 } |
| 418 | 419 |
| 419 // andpd, cmpltsd, movaps, psllq, psrlq, por. | 420 // andpd, cmpltsd, movaps, psllq, psrlq, por. |
| 420 { | 421 { |
| 421 if (CpuFeatures::IsSupported(SSE2)) { | 422 if (Isolate::Current()->cpu_features()->IsSupported(SSE2)) { |
| 422 CpuFeatures::Scope fscope(SSE2); | 423 CpuFeatures::Scope fscope(SSE2); |
| 423 __ andpd(xmm0, xmm1); | 424 __ andpd(xmm0, xmm1); |
| 424 __ andpd(xmm1, xmm2); | 425 __ andpd(xmm1, xmm2); |
| 425 | 426 |
| 426 __ cmpltsd(xmm0, xmm1); | 427 __ cmpltsd(xmm0, xmm1); |
| 427 __ cmpltsd(xmm1, xmm2); | 428 __ cmpltsd(xmm1, xmm2); |
| 428 | 429 |
| 429 __ movaps(xmm0, xmm1); | 430 __ movaps(xmm0, xmm1); |
| 430 __ movaps(xmm1, xmm2); | 431 __ movaps(xmm1, xmm2); |
| 431 | 432 |
| 432 __ psllq(xmm0, 17); | 433 __ psllq(xmm0, 17); |
| 433 __ psllq(xmm1, 42); | 434 __ psllq(xmm1, 42); |
| 434 | 435 |
| 435 __ psllq(xmm0, xmm1); | 436 __ psllq(xmm0, xmm1); |
| 436 __ psllq(xmm1, xmm2); | 437 __ psllq(xmm1, xmm2); |
| 437 | 438 |
| 438 __ psrlq(xmm0, 17); | 439 __ psrlq(xmm0, 17); |
| 439 __ psrlq(xmm1, 42); | 440 __ psrlq(xmm1, 42); |
| 440 | 441 |
| 441 __ psrlq(xmm0, xmm1); | 442 __ psrlq(xmm0, xmm1); |
| 442 __ psrlq(xmm1, xmm2); | 443 __ psrlq(xmm1, xmm2); |
| 443 | 444 |
| 444 __ por(xmm0, xmm1); | 445 __ por(xmm0, xmm1); |
| 445 __ por(xmm1, xmm2); | 446 __ por(xmm1, xmm2); |
| 446 } | 447 } |
| 447 } | 448 } |
| 448 | 449 |
| 449 { | 450 { |
| 450 if (CpuFeatures::IsSupported(SSE4_1)) { | 451 if (Isolate::Current()->cpu_features()->IsSupported(SSE4_1)) { |
| 451 CpuFeatures::Scope scope(SSE4_1); | 452 CpuFeatures::Scope scope(SSE4_1); |
| 452 __ pextrd(Operand(eax), xmm0, 1); | 453 __ pextrd(Operand(eax), xmm0, 1); |
| 453 __ pinsrd(xmm1, Operand(eax), 0); | 454 __ pinsrd(xmm1, Operand(eax), 0); |
| 454 } | 455 } |
| 455 } | 456 } |
| 456 | 457 |
| 457 __ ret(0); | 458 __ ret(0); |
| 458 | 459 |
| 459 CodeDesc desc; | 460 CodeDesc desc; |
| 460 assm.GetCode(&desc); | 461 assm.GetCode(&desc); |
| 461 Object* code = Heap::CreateCode( | 462 Object* code = HEAP->CreateCode( |
| 462 desc, | 463 desc, |
| 463 Code::ComputeFlags(Code::STUB), | 464 Code::ComputeFlags(Code::STUB), |
| 464 Handle<Object>(Heap::undefined_value()))->ToObjectChecked(); | 465 Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); |
| 465 CHECK(code->IsCode()); | 466 CHECK(code->IsCode()); |
| 466 #ifdef OBJECT_PRINT | 467 #ifdef OBJECT_PRINT |
| 467 Code::cast(code)->Print(); | 468 Code::cast(code)->Print(); |
| 468 byte* begin = Code::cast(code)->instruction_start(); | 469 byte* begin = Code::cast(code)->instruction_start(); |
| 469 byte* end = begin + Code::cast(code)->instruction_size(); | 470 byte* end = begin + Code::cast(code)->instruction_size(); |
| 470 disasm::Disassembler::Disassemble(stdout, begin, end); | 471 disasm::Disassembler::Disassemble(stdout, begin, end); |
| 471 #endif | 472 #endif |
| 472 } | 473 } |
| 473 | 474 |
| 474 #undef __ | 475 #undef __ |
| OLD | NEW |