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

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

Issue 6597029: [Isolates] Merge r 6300:6500 from bleeding_edge to isolates. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: Created 9 years, 10 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/x64/code-stubs-x64.h ('k') | src/x64/codegen-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 2010 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
11 // with the distribution. 11 // with the distribution.
(...skipping 2760 matching lines...) Expand 10 before | Expand all | Expand 10 after
2772 __ bind(&skip); 2772 __ bind(&skip);
2773 __ ret(0); 2773 __ ret(0);
2774 } 2774 }
2775 2775
2776 2776
2777 void CEntryStub::GenerateCore(MacroAssembler* masm, 2777 void CEntryStub::GenerateCore(MacroAssembler* masm,
2778 Label* throw_normal_exception, 2778 Label* throw_normal_exception,
2779 Label* throw_termination_exception, 2779 Label* throw_termination_exception,
2780 Label* throw_out_of_memory_exception, 2780 Label* throw_out_of_memory_exception,
2781 bool do_gc, 2781 bool do_gc,
2782 bool always_allocate_scope, 2782 bool always_allocate_scope) {
2783 int /* alignment_skew */) {
2784 // rax: result parameter for PerformGC, if any. 2783 // rax: result parameter for PerformGC, if any.
2785 // rbx: pointer to C function (C callee-saved). 2784 // rbx: pointer to C function (C callee-saved).
2786 // rbp: frame pointer (restored after C call). 2785 // rbp: frame pointer (restored after C call).
2787 // rsp: stack pointer (restored after C call). 2786 // rsp: stack pointer (restored after C call).
2788 // r14: number of arguments including receiver (C callee-saved). 2787 // r14: number of arguments including receiver (C callee-saved).
2789 // r12: pointer to the first argument (C callee-saved). 2788 // r12: pointer to the first argument (C callee-saved).
2790 // This pointer is reused in LeaveExitFrame(), so it is stored in a 2789 // This pointer is reused in LeaveExitFrame(), so it is stored in a
2791 // callee-saved register. 2790 // callee-saved register.
2792 2791
2793 // Simple results returned in rax (both AMD64 and Win64 calling conventions). 2792 // Simple results returned in rax (both AMD64 and Win64 calling conventions).
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
2869 __ movq(rax, Operand(rsp, 6 * kPointerSize)); 2868 __ movq(rax, Operand(rsp, 6 * kPointerSize));
2870 __ movq(rdx, Operand(rsp, 7 * kPointerSize)); 2869 __ movq(rdx, Operand(rsp, 7 * kPointerSize));
2871 } 2870 }
2872 #endif 2871 #endif
2873 __ lea(rcx, Operand(rax, 1)); 2872 __ lea(rcx, Operand(rax, 1));
2874 // Lower 2 bits of rcx are 0 iff rax has failure tag. 2873 // Lower 2 bits of rcx are 0 iff rax has failure tag.
2875 __ testl(rcx, Immediate(kFailureTagMask)); 2874 __ testl(rcx, Immediate(kFailureTagMask));
2876 __ j(zero, &failure_returned); 2875 __ j(zero, &failure_returned);
2877 2876
2878 // Exit the JavaScript to C++ exit frame. 2877 // Exit the JavaScript to C++ exit frame.
2879 __ LeaveExitFrame(); 2878 __ LeaveExitFrame(save_doubles_);
2880 __ ret(0); 2879 __ ret(0);
2881 2880
2882 // Handling of failure. 2881 // Handling of failure.
2883 __ bind(&failure_returned); 2882 __ bind(&failure_returned);
2884 2883
2885 NearLabel retry; 2884 NearLabel retry;
2886 // If the returned exception is RETRY_AFTER_GC continue at retry label 2885 // If the returned exception is RETRY_AFTER_GC continue at retry label
2887 STATIC_ASSERT(Failure::RETRY_AFTER_GC == 0); 2886 STATIC_ASSERT(Failure::RETRY_AFTER_GC == 0);
2888 __ testl(rax, Immediate(((1 << kFailureTypeTagSize) - 1) << kFailureTagSize)); 2887 __ testl(rax, Immediate(((1 << kFailureTypeTagSize) - 1) << kFailureTagSize));
2889 __ j(zero, &retry); 2888 __ j(zero, &retry);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
2980 // instead of a proper result. The builtin entry handles 2979 // instead of a proper result. The builtin entry handles
2981 // this by performing a garbage collection and retrying the 2980 // this by performing a garbage collection and retrying the
2982 // builtin once. 2981 // builtin once.
2983 2982
2984 // Enter the exit frame that transitions from JavaScript to C++. 2983 // Enter the exit frame that transitions from JavaScript to C++.
2985 #ifdef _WIN64 2984 #ifdef _WIN64
2986 int arg_stack_space = (result_size_ < 2 ? 2 : 4); 2985 int arg_stack_space = (result_size_ < 2 ? 2 : 4);
2987 #else 2986 #else
2988 int arg_stack_space = 0; 2987 int arg_stack_space = 0;
2989 #endif 2988 #endif
2990 __ EnterExitFrame(arg_stack_space); 2989 __ EnterExitFrame(arg_stack_space, save_doubles_);
2991 2990
2992 // rax: Holds the context at this point, but should not be used. 2991 // rax: Holds the context at this point, but should not be used.
2993 // On entry to code generated by GenerateCore, it must hold 2992 // On entry to code generated by GenerateCore, it must hold
2994 // a failure result if the collect_garbage argument to GenerateCore 2993 // a failure result if the collect_garbage argument to GenerateCore
2995 // is true. This failure result can be the result of code 2994 // is true. This failure result can be the result of code
2996 // generated by a previous call to GenerateCore. The value 2995 // generated by a previous call to GenerateCore. The value
2997 // of rax is then passed to Runtime::PerformGC. 2996 // of rax is then passed to Runtime::PerformGC.
2998 // rbx: pointer to builtin function (C callee-saved). 2997 // rbx: pointer to builtin function (C callee-saved).
2999 // rbp: frame pointer of exit frame (restored after C call). 2998 // rbp: frame pointer of exit frame (restored after C call).
3000 // rsp: stack pointer (restored after C call). 2999 // rsp: stack pointer (restored after C call).
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
3251 // We have to store a non-zero value in the cache. 3250 // We have to store a non-zero value in the cache.
3252 __ StoreRoot(kScratchRegister, Heap::kInstanceofCacheAnswerRootIndex); 3251 __ StoreRoot(kScratchRegister, Heap::kInstanceofCacheAnswerRootIndex);
3253 __ ret(2 * kPointerSize); 3252 __ ret(2 * kPointerSize);
3254 3253
3255 // Slow-case: Go through the JavaScript implementation. 3254 // Slow-case: Go through the JavaScript implementation.
3256 __ bind(&slow); 3255 __ bind(&slow);
3257 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION); 3256 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION);
3258 } 3257 }
3259 3258
3260 3259
3260 Register InstanceofStub::left() { return rax; }
3261
3262
3263 Register InstanceofStub::right() { return rdx; }
3264
3265
3261 int CompareStub::MinorKey() { 3266 int CompareStub::MinorKey() {
3262 // Encode the three parameters in a unique 16 bit value. To avoid duplicate 3267 // Encode the three parameters in a unique 16 bit value. To avoid duplicate
3263 // stubs the never NaN NaN condition is only taken into account if the 3268 // stubs the never NaN NaN condition is only taken into account if the
3264 // condition is equals. 3269 // condition is equals.
3265 ASSERT(static_cast<unsigned>(cc_) < (1 << 12)); 3270 ASSERT(static_cast<unsigned>(cc_) < (1 << 12));
3266 ASSERT(lhs_.is(no_reg) && rhs_.is(no_reg)); 3271 ASSERT(lhs_.is(no_reg) && rhs_.is(no_reg));
3267 return ConditionField::encode(static_cast<unsigned>(cc_)) 3272 return ConditionField::encode(static_cast<unsigned>(cc_))
3268 | RegisterField::encode(false) // lhs_ and rhs_ are not used 3273 | RegisterField::encode(false) // lhs_ and rhs_ are not used
3269 | StrictField::encode(strict_) 3274 | StrictField::encode(strict_)
3270 | NeverNanNanField::encode(cc_ == equal ? never_nan_nan_ : false) 3275 | NeverNanNanField::encode(cc_ == equal ? never_nan_nan_ : false)
(...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after
4276 __ push(rcx); 4281 __ push(rcx);
4277 GenerateCompareFlatAsciiStrings(masm, rdx, rax, rcx, rbx, rdi, r8); 4282 GenerateCompareFlatAsciiStrings(masm, rdx, rax, rcx, rbx, rdi, r8);
4278 4283
4279 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) 4284 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater)
4280 // tagged as a small integer. 4285 // tagged as a small integer.
4281 __ bind(&runtime); 4286 __ bind(&runtime);
4282 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); 4287 __ TailCallRuntime(Runtime::kStringCompare, 2, 1);
4283 } 4288 }
4284 4289
4285 void ICCompareStub::GenerateSmis(MacroAssembler* masm) { 4290 void ICCompareStub::GenerateSmis(MacroAssembler* masm) {
4286 UNIMPLEMENTED(); 4291 ASSERT(state_ == CompareIC::SMIS);
4292 NearLabel miss;
4293 __ JumpIfNotBothSmi(rdx, rax, &miss);
4294
4295 if (GetCondition() == equal) {
4296 // For equality we do not care about the sign of the result.
4297 __ SmiSub(rax, rax, rdx);
4298 } else {
4299 NearLabel done;
4300 __ SmiSub(rdx, rdx, rax);
4301 __ j(no_overflow, &done);
4302 // Correct sign of result in case of overflow.
4303 __ SmiNot(rdx, rdx);
4304 __ bind(&done);
4305 __ movq(rax, rdx);
4306 }
4307 __ ret(0);
4308
4309 __ bind(&miss);
4310 GenerateMiss(masm);
4287 } 4311 }
4288 4312
4289 4313
4290 void ICCompareStub::GenerateHeapNumbers(MacroAssembler* masm) { 4314 void ICCompareStub::GenerateHeapNumbers(MacroAssembler* masm) {
4291 UNIMPLEMENTED(); 4315 ASSERT(state_ == CompareIC::HEAP_NUMBERS);
4316
4317 NearLabel generic_stub;
4318 NearLabel unordered;
4319 NearLabel miss;
4320 Condition either_smi = masm->CheckEitherSmi(rax, rdx);
4321 __ j(either_smi, &generic_stub);
4322
4323 __ CmpObjectType(rax, HEAP_NUMBER_TYPE, rcx);
4324 __ j(not_equal, &miss);
4325 __ CmpObjectType(rdx, HEAP_NUMBER_TYPE, rcx);
4326 __ j(not_equal, &miss);
4327
4328 // Load left and right operand
4329 __ movsd(xmm0, FieldOperand(rdx, HeapNumber::kValueOffset));
4330 __ movsd(xmm1, FieldOperand(rax, HeapNumber::kValueOffset));
4331
4332 // Compare operands
4333 __ ucomisd(xmm0, xmm1);
4334
4335 // Don't base result on EFLAGS when a NaN is involved.
4336 __ j(parity_even, &unordered);
4337
4338 // Return a result of -1, 0, or 1, based on EFLAGS.
4339 // Performing mov, because xor would destroy the flag register.
4340 __ movl(rax, Immediate(0));
4341 __ movl(rcx, Immediate(0));
4342 __ setcc(above, rax); // Add one to zero if carry clear and not equal.
4343 __ sbbq(rax, rcx); // Subtract one if below (aka. carry set).
4344 __ ret(0);
4345
4346 __ bind(&unordered);
4347
4348 CompareStub stub(GetCondition(), strict(), NO_COMPARE_FLAGS);
4349 __ bind(&generic_stub);
4350 __ jmp(stub.GetCode(), RelocInfo::CODE_TARGET);
4351
4352 __ bind(&miss);
4353 GenerateMiss(masm);
4292 } 4354 }
4293 4355
4294 4356
4295 void ICCompareStub::GenerateObjects(MacroAssembler* masm) { 4357 void ICCompareStub::GenerateObjects(MacroAssembler* masm) {
4296 UNIMPLEMENTED(); 4358 ASSERT(state_ == CompareIC::OBJECTS);
4359 NearLabel miss;
4360 Condition either_smi = masm->CheckEitherSmi(rdx, rax);
4361 __ j(either_smi, &miss);
4362
4363 __ CmpObjectType(rax, JS_OBJECT_TYPE, rcx);
4364 __ j(not_equal, &miss, not_taken);
4365 __ CmpObjectType(rdx, JS_OBJECT_TYPE, rcx);
4366 __ j(not_equal, &miss, not_taken);
4367
4368 ASSERT(GetCondition() == equal);
4369 __ subq(rax, rdx);
4370 __ ret(0);
4371
4372 __ bind(&miss);
4373 GenerateMiss(masm);
4297 } 4374 }
4298 4375
4299 4376
4300 void ICCompareStub::GenerateMiss(MacroAssembler* masm) { 4377 void ICCompareStub::GenerateMiss(MacroAssembler* masm) {
4301 UNIMPLEMENTED(); 4378 // Save the registers.
4379 __ pop(rcx);
4380 __ push(rdx);
4381 __ push(rax);
4382 __ push(rcx);
4383
4384 // Call the runtime system in a fresh internal frame.
4385 ExternalReference miss = ExternalReference(IC_Utility(IC::kCompareIC_Miss));
4386 __ EnterInternalFrame();
4387 __ push(rdx);
4388 __ push(rax);
4389 __ Push(Smi::FromInt(op_));
4390 __ CallExternalReference(miss, 3);
4391 __ LeaveInternalFrame();
4392
4393 // Compute the entry point of the rewritten stub.
4394 __ lea(rdi, FieldOperand(rax, Code::kHeaderSize));
4395
4396 // Restore registers.
4397 __ pop(rcx);
4398 __ pop(rax);
4399 __ pop(rdx);
4400 __ push(rcx);
4401
4402 // Do a tail call to the rewritten stub.
4403 __ jmp(rdi);
4302 } 4404 }
4303 4405
4304 #undef __ 4406 #undef __
4305 4407
4306 } } // namespace v8::internal 4408 } } // namespace v8::internal
4307 4409
4308 #endif // V8_TARGET_ARCH_X64 4410 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/code-stubs-x64.h ('k') | src/x64/codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698