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

Side by Side Diff: src/ia32/code-stubs-ia32.cc

Issue 10701054: Enable stub generation using Hydrogen/Lithium (again) (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review feedback Created 8 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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 22 matching lines...) Expand all
33 #include "code-stubs.h" 33 #include "code-stubs.h"
34 #include "isolate.h" 34 #include "isolate.h"
35 #include "jsregexp.h" 35 #include "jsregexp.h"
36 #include "regexp-macro-assembler.h" 36 #include "regexp-macro-assembler.h"
37 #include "stub-cache.h" 37 #include "stub-cache.h"
38 #include "codegen.h" 38 #include "codegen.h"
39 39
40 namespace v8 { 40 namespace v8 {
41 namespace internal { 41 namespace internal {
42 42
43
44 CodeStubInterfaceDescriptor*
45 KeyedLoadFastElementStub::GetInterfaceDescriptor(Isolate* isolate) {
Jakob Kummerow 2012/11/28 16:28:22 nit: indentation please
danno 2012/11/30 16:23:24 Done.
46 static bool initialized = false;
47 static CodeStubInterfaceDescriptor* result;
Jakob Kummerow 2012/11/28 16:28:22 I'd suspect at least one of the common compilers t
danno 2012/11/30 16:23:24 Done.
48 if (!initialized) {
49 Handle<Code> miss = isolate->builtins()->KeyedLoadIC_Miss();
50 static Register registers[] = { edx, ecx };
51 static CodeStubInterfaceDescriptor info = {
52 2,
53 registers,
54 miss
55 };
56 result = &info;
57 }
58 return result;
59 }
60
61
43 #define __ ACCESS_MASM(masm) 62 #define __ ACCESS_MASM(masm)
44 63
45 void ToNumberStub::Generate(MacroAssembler* masm) { 64 void ToNumberStub::Generate(MacroAssembler* masm) {
46 // The ToNumber stub takes one argument in eax. 65 // The ToNumber stub takes one argument in eax.
47 Label check_heap_number, call_builtin; 66 Label check_heap_number, call_builtin;
48 __ JumpIfNotSmi(eax, &check_heap_number, Label::kNear); 67 __ JumpIfNotSmi(eax, &check_heap_number, Label::kNear);
49 __ ret(0); 68 __ ret(0);
50 69
51 __ bind(&check_heap_number); 70 __ bind(&check_heap_number);
52 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); 71 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset));
(...skipping 2366 matching lines...) Expand 10 before | Expand all | Expand 10 after
2419 __ cmp(ebx, Immediate(factory->heap_number_map())); 2438 __ cmp(ebx, Immediate(factory->heap_number_map()));
2420 __ j(not_equal, &runtime_call); 2439 __ j(not_equal, &runtime_call);
2421 // Input is a HeapNumber. Push it on the FPU stack and load its 2440 // Input is a HeapNumber. Push it on the FPU stack and load its
2422 // low and high words into ebx, edx. 2441 // low and high words into ebx, edx.
2423 __ fld_d(FieldOperand(eax, HeapNumber::kValueOffset)); 2442 __ fld_d(FieldOperand(eax, HeapNumber::kValueOffset));
2424 __ mov(edx, FieldOperand(eax, HeapNumber::kExponentOffset)); 2443 __ mov(edx, FieldOperand(eax, HeapNumber::kExponentOffset));
2425 __ mov(ebx, FieldOperand(eax, HeapNumber::kMantissaOffset)); 2444 __ mov(ebx, FieldOperand(eax, HeapNumber::kMantissaOffset));
2426 2445
2427 __ bind(&loaded); 2446 __ bind(&loaded);
2428 } else { // UNTAGGED. 2447 } else { // UNTAGGED.
2448 CpuFeatures::Scope scope(SSE2);
2429 if (CpuFeatures::IsSupported(SSE4_1)) { 2449 if (CpuFeatures::IsSupported(SSE4_1)) {
2430 CpuFeatures::Scope sse4_scope(SSE4_1); 2450 CpuFeatures::Scope sse4_scope(SSE4_1);
2431 __ pextrd(edx, xmm1, 0x1); // copy xmm1[63..32] to edx. 2451 __ pextrd(edx, xmm1, 0x1); // copy xmm1[63..32] to edx.
2432 } else { 2452 } else {
2433 __ pshufd(xmm0, xmm1, 0x1); 2453 __ pshufd(xmm0, xmm1, 0x1);
2434 __ movd(edx, xmm0); 2454 __ movd(edx, xmm0);
2435 } 2455 }
2436 __ movd(ebx, xmm1); 2456 __ movd(ebx, xmm1);
2437 } 2457 }
2438 2458
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
2491 __ cmp(edx, Operand(ecx, kIntSize)); 2511 __ cmp(edx, Operand(ecx, kIntSize));
2492 __ j(not_equal, &cache_miss, Label::kNear); 2512 __ j(not_equal, &cache_miss, Label::kNear);
2493 // Cache hit! 2513 // Cache hit!
2494 Counters* counters = masm->isolate()->counters(); 2514 Counters* counters = masm->isolate()->counters();
2495 __ IncrementCounter(counters->transcendental_cache_hit(), 1); 2515 __ IncrementCounter(counters->transcendental_cache_hit(), 1);
2496 __ mov(eax, Operand(ecx, 2 * kIntSize)); 2516 __ mov(eax, Operand(ecx, 2 * kIntSize));
2497 if (tagged) { 2517 if (tagged) {
2498 __ fstp(0); 2518 __ fstp(0);
2499 __ ret(kPointerSize); 2519 __ ret(kPointerSize);
2500 } else { // UNTAGGED. 2520 } else { // UNTAGGED.
2521 CpuFeatures::Scope scope(SSE2);
2501 __ movdbl(xmm1, FieldOperand(eax, HeapNumber::kValueOffset)); 2522 __ movdbl(xmm1, FieldOperand(eax, HeapNumber::kValueOffset));
2502 __ Ret(); 2523 __ Ret();
2503 } 2524 }
2504 2525
2505 __ bind(&cache_miss); 2526 __ bind(&cache_miss);
2506 __ IncrementCounter(counters->transcendental_cache_miss(), 1); 2527 __ IncrementCounter(counters->transcendental_cache_miss(), 1);
2507 // Update cache with new value. 2528 // Update cache with new value.
2508 // We are short on registers, so use no_reg as scratch. 2529 // We are short on registers, so use no_reg as scratch.
2509 // This gives slightly larger code. 2530 // This gives slightly larger code.
2510 if (tagged) { 2531 if (tagged) {
2511 __ AllocateHeapNumber(eax, edi, no_reg, &runtime_call_clear_stack); 2532 __ AllocateHeapNumber(eax, edi, no_reg, &runtime_call_clear_stack);
2512 } else { // UNTAGGED. 2533 } else { // UNTAGGED.
2534 CpuFeatures::Scope scope(SSE2);
2513 __ AllocateHeapNumber(eax, edi, no_reg, &skip_cache); 2535 __ AllocateHeapNumber(eax, edi, no_reg, &skip_cache);
2514 __ sub(esp, Immediate(kDoubleSize)); 2536 __ sub(esp, Immediate(kDoubleSize));
2515 __ movdbl(Operand(esp, 0), xmm1); 2537 __ movdbl(Operand(esp, 0), xmm1);
2516 __ fld_d(Operand(esp, 0)); 2538 __ fld_d(Operand(esp, 0));
2517 __ add(esp, Immediate(kDoubleSize)); 2539 __ add(esp, Immediate(kDoubleSize));
2518 } 2540 }
2519 GenerateOperation(masm, type_); 2541 GenerateOperation(masm, type_);
2520 __ mov(Operand(ecx, 0), ebx); 2542 __ mov(Operand(ecx, 0), ebx);
2521 __ mov(Operand(ecx, kIntSize), edx); 2543 __ mov(Operand(ecx, kIntSize), edx);
2522 __ mov(Operand(ecx, 2 * kIntSize), eax); 2544 __ mov(Operand(ecx, 2 * kIntSize), eax);
2523 __ fstp_d(FieldOperand(eax, HeapNumber::kValueOffset)); 2545 __ fstp_d(FieldOperand(eax, HeapNumber::kValueOffset));
2524 if (tagged) { 2546 if (tagged) {
2525 __ ret(kPointerSize); 2547 __ ret(kPointerSize);
2526 } else { // UNTAGGED. 2548 } else { // UNTAGGED.
2549 CpuFeatures::Scope scope(SSE2);
2527 __ movdbl(xmm1, FieldOperand(eax, HeapNumber::kValueOffset)); 2550 __ movdbl(xmm1, FieldOperand(eax, HeapNumber::kValueOffset));
2528 __ Ret(); 2551 __ Ret();
2529 2552
2530 // Skip cache and return answer directly, only in untagged case. 2553 // Skip cache and return answer directly, only in untagged case.
2531 __ bind(&skip_cache); 2554 __ bind(&skip_cache);
2532 __ sub(esp, Immediate(kDoubleSize)); 2555 __ sub(esp, Immediate(kDoubleSize));
2533 __ movdbl(Operand(esp, 0), xmm1); 2556 __ movdbl(Operand(esp, 0), xmm1);
2534 __ fld_d(Operand(esp, 0)); 2557 __ fld_d(Operand(esp, 0));
2535 GenerateOperation(masm, type_); 2558 GenerateOperation(masm, type_);
2536 __ fstp_d(Operand(esp, 0)); 2559 __ fstp_d(Operand(esp, 0));
(...skipping 12 matching lines...) Expand all
2549 2572
2550 // Call runtime, doing whatever allocation and cleanup is necessary. 2573 // Call runtime, doing whatever allocation and cleanup is necessary.
2551 if (tagged) { 2574 if (tagged) {
2552 __ bind(&runtime_call_clear_stack); 2575 __ bind(&runtime_call_clear_stack);
2553 __ fstp(0); 2576 __ fstp(0);
2554 __ bind(&runtime_call); 2577 __ bind(&runtime_call);
2555 ExternalReference runtime = 2578 ExternalReference runtime =
2556 ExternalReference(RuntimeFunction(), masm->isolate()); 2579 ExternalReference(RuntimeFunction(), masm->isolate());
2557 __ TailCallExternalReference(runtime, 1, 1); 2580 __ TailCallExternalReference(runtime, 1, 1);
2558 } else { // UNTAGGED. 2581 } else { // UNTAGGED.
2582 CpuFeatures::Scope scope(SSE2);
2559 __ bind(&runtime_call_clear_stack); 2583 __ bind(&runtime_call_clear_stack);
2560 __ bind(&runtime_call); 2584 __ bind(&runtime_call);
2561 __ AllocateHeapNumber(eax, edi, no_reg, &skip_cache); 2585 __ AllocateHeapNumber(eax, edi, no_reg, &skip_cache);
2562 __ movdbl(FieldOperand(eax, HeapNumber::kValueOffset), xmm1); 2586 __ movdbl(FieldOperand(eax, HeapNumber::kValueOffset), xmm1);
2563 { 2587 {
2564 FrameScope scope(masm, StackFrame::INTERNAL); 2588 FrameScope scope(masm, StackFrame::INTERNAL);
2565 __ push(eax); 2589 __ push(eax);
2566 __ CallRuntime(RuntimeFunction(), 1); 2590 __ CallRuntime(RuntimeFunction(), 1);
2567 } 2591 }
2568 __ movdbl(xmm1, FieldOperand(eax, HeapNumber::kValueOffset)); 2592 __ movdbl(xmm1, FieldOperand(eax, HeapNumber::kValueOffset));
(...skipping 2232 matching lines...) Expand 10 before | Expand all | Expand 10 after
4801 4825
4802 void CodeStub::GenerateStubsAheadOfTime() { 4826 void CodeStub::GenerateStubsAheadOfTime() {
4803 CEntryStub::GenerateAheadOfTime(); 4827 CEntryStub::GenerateAheadOfTime();
4804 StoreBufferOverflowStub::GenerateFixedRegStubsAheadOfTime(); 4828 StoreBufferOverflowStub::GenerateFixedRegStubsAheadOfTime();
4805 // It is important that the store buffer overflow stubs are generated first. 4829 // It is important that the store buffer overflow stubs are generated first.
4806 RecordWriteStub::GenerateFixedRegStubsAheadOfTime(); 4830 RecordWriteStub::GenerateFixedRegStubsAheadOfTime();
4807 } 4831 }
4808 4832
4809 4833
4810 void CodeStub::GenerateFPStubs() { 4834 void CodeStub::GenerateFPStubs() {
4811 CEntryStub save_doubles(1, kSaveFPRegs); 4835 if (CpuFeatures::IsSupported(SSE2)) {
4812 Handle<Code> code = save_doubles.GetCode(); 4836 CEntryStub save_doubles(1, kSaveFPRegs);
4813 code->set_is_pregenerated(true); 4837 Handle<Code> code = save_doubles.GetCode();
4814 code->GetIsolate()->set_fp_stubs_generated(true); 4838 code->set_is_pregenerated(true);
4839 code->GetIsolate()->set_fp_stubs_generated(true);
4840 }
4815 } 4841 }
4816 4842
4817 4843
4818 void CEntryStub::GenerateAheadOfTime() { 4844 void CEntryStub::GenerateAheadOfTime() {
4819 CEntryStub stub(1, kDontSaveFPRegs); 4845 CEntryStub stub(1, kDontSaveFPRegs);
4820 Handle<Code> code = stub.GetCode(); 4846 Handle<Code> code = stub.GetCode();
4821 code->set_is_pregenerated(true); 4847 code->set_is_pregenerated(true);
4822 } 4848 }
4823 4849
4824 4850
(...skipping 2624 matching lines...) Expand 10 before | Expand all | Expand 10 after
7449 // Restore ecx. 7475 // Restore ecx.
7450 __ pop(ecx); 7476 __ pop(ecx);
7451 __ ret(0); 7477 __ ret(0);
7452 } 7478 }
7453 7479
7454 #undef __ 7480 #undef __
7455 7481
7456 } } // namespace v8::internal 7482 } } // namespace v8::internal
7457 7483
7458 #endif // V8_TARGET_ARCH_IA32 7484 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698