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

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

Issue 6606006: [Isolates] Merge 6500:6700 from bleeding_edge to isolates. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: '' Created 9 years, 9 months 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 | « src/ia32/code-stubs-ia32.h ('k') | src/ia32/codegen-ia32.h » ('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 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 21 matching lines...) Expand all
32 #include "code-stubs.h" 32 #include "code-stubs.h"
33 #include "bootstrapper.h" 33 #include "bootstrapper.h"
34 #include "jsregexp.h" 34 #include "jsregexp.h"
35 #include "isolate.h" 35 #include "isolate.h"
36 #include "regexp-macro-assembler.h" 36 #include "regexp-macro-assembler.h"
37 37
38 namespace v8 { 38 namespace v8 {
39 namespace internal { 39 namespace internal {
40 40
41 #define __ ACCESS_MASM(masm) 41 #define __ ACCESS_MASM(masm)
42
43 void ToNumberStub::Generate(MacroAssembler* masm) {
44 // The ToNumber stub takes one argument in eax.
45 NearLabel check_heap_number, call_builtin;
46 __ test(eax, Immediate(kSmiTagMask));
47 __ j(not_zero, &check_heap_number);
48 __ ret(0);
49
50 __ bind(&check_heap_number);
51 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset));
52 __ cmp(Operand(ebx), Immediate(FACTORY->heap_number_map()));
53 __ j(not_equal, &call_builtin);
54 __ ret(0);
55
56 __ bind(&call_builtin);
57 __ pop(ecx); // Pop return address.
58 __ push(eax);
59 __ push(ecx); // Push return address.
60 __ InvokeBuiltin(Builtins::TO_NUMBER, JUMP_FUNCTION);
61 }
62
63
42 void FastNewClosureStub::Generate(MacroAssembler* masm) { 64 void FastNewClosureStub::Generate(MacroAssembler* masm) {
43 // Create a new closure from the given function info in new 65 // Create a new closure from the given function info in new
44 // space. Set the context to the current context in esi. 66 // space. Set the context to the current context in esi.
45 Label gc; 67 Label gc;
46 __ AllocateInNewSpace(JSFunction::kSize, eax, ebx, ecx, &gc, TAG_OBJECT); 68 __ AllocateInNewSpace(JSFunction::kSize, eax, ebx, ecx, &gc, TAG_OBJECT);
47 69
48 // Get the function info from the stack. 70 // Get the function info from the stack.
49 __ mov(edx, Operand(esp, 1 * kPointerSize)); 71 __ mov(edx, Operand(esp, 1 * kPointerSize));
50 72
51 // Compute the function map in the current global context and set that 73 // Compute the function map in the current global context and set that
(...skipping 3424 matching lines...) Expand 10 before | Expand all | Expand 10 after
3476 // Test for -0.5. 3498 // Test for -0.5.
3477 // Load xmm2 with -0.5. 3499 // Load xmm2 with -0.5.
3478 __ mov(ecx, Immediate(0xBF000000)); 3500 __ mov(ecx, Immediate(0xBF000000));
3479 __ movd(xmm2, Operand(ecx)); 3501 __ movd(xmm2, Operand(ecx));
3480 __ cvtss2sd(xmm2, xmm2); 3502 __ cvtss2sd(xmm2, xmm2);
3481 // xmm2 now has -0.5. 3503 // xmm2 now has -0.5.
3482 __ ucomisd(xmm2, xmm1); 3504 __ ucomisd(xmm2, xmm1);
3483 __ j(not_equal, &not_minus_half); 3505 __ j(not_equal, &not_minus_half);
3484 3506
3485 // Calculates reciprocal of square root. 3507 // Calculates reciprocal of square root.
3486 // Note that 1/sqrt(x) = sqrt(1/x)) 3508 // sqrtsd returns -0 when input is -0. ECMA spec requires +0.
3487 __ divsd(xmm3, xmm0); 3509 __ xorpd(xmm1, xmm1);
3510 __ addsd(xmm1, xmm0);
3511 __ sqrtsd(xmm1, xmm1);
3512 __ divsd(xmm3, xmm1);
3488 __ movsd(xmm1, xmm3); 3513 __ movsd(xmm1, xmm3);
3489 __ sqrtsd(xmm1, xmm1);
3490 __ jmp(&allocate_return); 3514 __ jmp(&allocate_return);
3491 3515
3492 // Test for 0.5. 3516 // Test for 0.5.
3493 __ bind(&not_minus_half); 3517 __ bind(&not_minus_half);
3494 // Load xmm2 with 0.5. 3518 // Load xmm2 with 0.5.
3495 // Since xmm3 is 1 and xmm2 is -0.5 this is simply xmm2 + xmm3. 3519 // Since xmm3 is 1 and xmm2 is -0.5 this is simply xmm2 + xmm3.
3496 __ addsd(xmm2, xmm3); 3520 __ addsd(xmm2, xmm3);
3497 // xmm2 now has 0.5. 3521 // xmm2 now has 0.5.
3498 __ ucomisd(xmm2, xmm1); 3522 __ ucomisd(xmm2, xmm1);
3499 __ j(not_equal, &call_runtime); 3523 __ j(not_equal, &call_runtime);
3500 // Calculates square root. 3524 // Calculates square root.
3501 __ movsd(xmm1, xmm0); 3525 // sqrtsd returns -0 when input is -0. ECMA spec requires +0.
3526 __ xorpd(xmm1, xmm1);
3527 __ addsd(xmm1, xmm0);
3502 __ sqrtsd(xmm1, xmm1); 3528 __ sqrtsd(xmm1, xmm1);
3503 3529
3504 __ bind(&allocate_return); 3530 __ bind(&allocate_return);
3505 __ AllocateHeapNumber(ecx, eax, edx, &call_runtime); 3531 __ AllocateHeapNumber(ecx, eax, edx, &call_runtime);
3506 __ movdbl(FieldOperand(ecx, HeapNumber::kValueOffset), xmm1); 3532 __ movdbl(FieldOperand(ecx, HeapNumber::kValueOffset), xmm1);
3507 __ mov(eax, ecx); 3533 __ mov(eax, ecx);
3508 __ ret(2); 3534 __ ret(2);
3509 3535
3510 __ bind(&call_runtime); 3536 __ bind(&call_runtime);
3511 __ TailCallRuntime(Runtime::kMath_pow_cfunction, 2, 1); 3537 __ TailCallRuntime(Runtime::kMath_pow_cfunction, 2, 1);
(...skipping 1187 matching lines...) Expand 10 before | Expand all | Expand 10 after
4699 } 4725 }
4700 4726
4701 // Check for failure result. 4727 // Check for failure result.
4702 Label failure_returned; 4728 Label failure_returned;
4703 STATIC_ASSERT(((kFailureTag + 1) & kFailureTagMask) == 0); 4729 STATIC_ASSERT(((kFailureTag + 1) & kFailureTagMask) == 0);
4704 __ lea(ecx, Operand(eax, 1)); 4730 __ lea(ecx, Operand(eax, 1));
4705 // Lower 2 bits of ecx are 0 iff eax has failure tag. 4731 // Lower 2 bits of ecx are 0 iff eax has failure tag.
4706 __ test(ecx, Immediate(kFailureTagMask)); 4732 __ test(ecx, Immediate(kFailureTagMask));
4707 __ j(zero, &failure_returned, not_taken); 4733 __ j(zero, &failure_returned, not_taken);
4708 4734
4735 ExternalReference pending_exception_address(
4736 Isolate::k_pending_exception_address);
4737
4738 // Check that there is no pending exception, otherwise we
4739 // should have returned some failure value.
4740 if (FLAG_debug_code) {
4741 __ push(edx);
4742 __ mov(edx, Operand::StaticVariable(
4743 ExternalReference::the_hole_value_location()));
4744 NearLabel okay;
4745 __ cmp(edx, Operand::StaticVariable(pending_exception_address));
4746 // Cannot use check here as it attempts to generate call into runtime.
4747 __ j(equal, &okay);
4748 __ int3();
4749 __ bind(&okay);
4750 __ pop(edx);
4751 }
4752
4709 // Exit the JavaScript to C++ exit frame. 4753 // Exit the JavaScript to C++ exit frame.
4710 __ LeaveExitFrame(save_doubles_); 4754 __ LeaveExitFrame(save_doubles_);
4711 __ ret(0); 4755 __ ret(0);
4712 4756
4713 // Handling of failure. 4757 // Handling of failure.
4714 __ bind(&failure_returned); 4758 __ bind(&failure_returned);
4715 4759
4716 Label retry; 4760 Label retry;
4717 // If the returned exception is RETRY_AFTER_GC continue at retry label 4761 // If the returned exception is RETRY_AFTER_GC continue at retry label
4718 STATIC_ASSERT(Failure::RETRY_AFTER_GC == 0); 4762 STATIC_ASSERT(Failure::RETRY_AFTER_GC == 0);
4719 __ test(eax, Immediate(((1 << kFailureTypeTagSize) - 1) << kFailureTagSize)); 4763 __ test(eax, Immediate(((1 << kFailureTypeTagSize) - 1) << kFailureTagSize));
4720 __ j(zero, &retry, taken); 4764 __ j(zero, &retry, taken);
4721 4765
4722 // Special handling of out of memory exceptions. 4766 // Special handling of out of memory exceptions.
4723 __ cmp(eax, reinterpret_cast<int32_t>(Failure::OutOfMemoryException())); 4767 __ cmp(eax, reinterpret_cast<int32_t>(Failure::OutOfMemoryException()));
4724 __ j(equal, throw_out_of_memory_exception); 4768 __ j(equal, throw_out_of_memory_exception);
4725 4769
4726 // Retrieve the pending exception and clear the variable. 4770 // Retrieve the pending exception and clear the variable.
4727 ExternalReference pending_exception_address(
4728 Isolate::k_pending_exception_address);
4729 __ mov(eax, Operand::StaticVariable(pending_exception_address)); 4771 __ mov(eax, Operand::StaticVariable(pending_exception_address));
4730 __ mov(edx, 4772 __ mov(edx,
4731 Operand::StaticVariable(ExternalReference::the_hole_value_location())); 4773 Operand::StaticVariable(ExternalReference::the_hole_value_location()));
4732 __ mov(Operand::StaticVariable(pending_exception_address), edx); 4774 __ mov(Operand::StaticVariable(pending_exception_address), edx);
4733 4775
4734 // Special handling of termination exceptions which are uncatchable 4776 // Special handling of termination exceptions which are uncatchable
4735 // by javascript code. 4777 // by javascript code.
4736 __ cmp(eax, FACTORY->termination_exception()); 4778 __ cmp(eax, FACTORY->termination_exception());
4737 __ j(equal, throw_termination_exception); 4779 __ j(equal, throw_termination_exception);
4738 4780
(...skipping 1754 matching lines...) Expand 10 before | Expand all | Expand 10 after
6493 __ pop(ecx); 6535 __ pop(ecx);
6494 __ pop(eax); 6536 __ pop(eax);
6495 __ pop(edx); 6537 __ pop(edx);
6496 __ push(ecx); 6538 __ push(ecx);
6497 6539
6498 // Do a tail call to the rewritten stub. 6540 // Do a tail call to the rewritten stub.
6499 __ jmp(Operand(edi)); 6541 __ jmp(Operand(edi));
6500 } 6542 }
6501 6543
6502 6544
6545 // Loads a indexed element from a pixel array.
6546 void GenerateFastPixelArrayLoad(MacroAssembler* masm,
6547 Register receiver,
6548 Register key,
6549 Register elements,
6550 Register untagged_key,
6551 Register result,
6552 Label* not_pixel_array,
6553 Label* key_not_smi,
6554 Label* out_of_range) {
6555 // Register use:
6556 // receiver - holds the receiver and is unchanged.
6557 // key - holds the key and is unchanged (must be a smi).
6558 // elements - is set to the the receiver's element if
6559 // the receiver doesn't have a pixel array or the
6560 // key is not a smi, otherwise it's the elements'
6561 // external pointer.
6562 // untagged_key - is set to the untagged key
6563
6564 // Some callers already have verified that the key is a smi. key_not_smi is
6565 // set to NULL as a sentinel for that case. Otherwise, add an explicit check
6566 // to ensure the key is a smi must be added.
6567 if (key_not_smi != NULL) {
6568 __ JumpIfNotSmi(key, key_not_smi);
6569 } else {
6570 if (FLAG_debug_code) {
6571 __ AbortIfNotSmi(key);
6572 }
6573 }
6574 __ mov(untagged_key, key);
6575 __ SmiUntag(untagged_key);
6576
6577 // Verify that the receiver has pixel array elements.
6578 __ mov(elements, FieldOperand(receiver, JSObject::kElementsOffset));
6579 __ CheckMap(elements, FACTORY->pixel_array_map(), not_pixel_array, true);
6580
6581 // Key must be in range.
6582 __ cmp(untagged_key, FieldOperand(elements, PixelArray::kLengthOffset));
6583 __ j(above_equal, out_of_range); // unsigned check handles negative keys.
6584
6585 // Perform the indexed load and tag the result as a smi.
6586 __ mov(elements, FieldOperand(elements, PixelArray::kExternalPointerOffset));
6587 __ movzx_b(result, Operand(elements, untagged_key, times_1, 0));
6588 __ SmiTag(result);
6589 __ ret(0);
6590 }
6591
6592
6503 #undef __ 6593 #undef __
6504 6594
6505 } } // namespace v8::internal 6595 } } // namespace v8::internal
6506 6596
6507 #endif // V8_TARGET_ARCH_IA32 6597 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/code-stubs-ia32.h ('k') | src/ia32/codegen-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698