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

Side by Side Diff: src/x64/codegen-x64.cc

Issue 151077: X64: Add Math.random, fix UnarySubStub (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 5 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 3318 matching lines...) Expand 10 before | Expand all | Expand 10 after
3329 Result left = frame_->Pop(); 3329 Result left = frame_->Pop();
3330 right.ToRegister(); 3330 right.ToRegister();
3331 left.ToRegister(); 3331 left.ToRegister();
3332 __ cmpq(right.reg(), left.reg()); 3332 __ cmpq(right.reg(), left.reg());
3333 right.Unuse(); 3333 right.Unuse();
3334 left.Unuse(); 3334 left.Unuse();
3335 destination()->Split(equal); 3335 destination()->Split(equal);
3336 } 3336 }
3337 3337
3338 3338
3339 void CodeGenerator::GenerateRandomPositiveSmi(ZoneList<Expression*>* args) {
3340 ASSERT(args->length() == 0);
3341 frame_->SpillAll();
3339 3342
3340 void CodeGenerator::GenerateRandomPositiveSmi(ZoneList<Expression*>* a) { 3343 // Make sure the frame is aligned like the OS expects.
3341 UNIMPLEMENTED(); 3344 static const int kFrameAlignment = OS::ActivationFrameAlignment();
3345 if (kFrameAlignment > 0) {
3346 ASSERT(IsPowerOf2(kFrameAlignment));
3347 __ movq(rbx, rsp); // Save in AMD-64 abi callee-saved register.
3348 __ and_(rsp, Immediate(-kFrameAlignment));
3349 }
3350
3351 // Call V8::RandomPositiveSmi().
3352 __ Call(FUNCTION_ADDR(V8::RandomPositiveSmi), RelocInfo::RUNTIME_ENTRY);
3353
3354 // Restore stack pointer from callee-saved register edi.
3355 if (kFrameAlignment > 0) {
3356 __ movq(rsp, rbx);
3357 }
3358
3359 Result result = allocator_->Allocate(rax);
3360 frame_->Push(&result);
3342 } 3361 }
3343 3362
3363
3344 void CodeGenerator::GenerateFastMathOp(MathOp op, ZoneList<Expression*>* args) { 3364 void CodeGenerator::GenerateFastMathOp(MathOp op, ZoneList<Expression*>* args) {
3345 UNIMPLEMENTED(); 3365 UNIMPLEMENTED();
3346 } 3366 }
3347 3367
3348 3368
3349 void CodeGenerator::GenerateClassOf(ZoneList<Expression*>* args) { 3369 void CodeGenerator::GenerateClassOf(ZoneList<Expression*>* args) {
3350 // TODO(X64): Optimize this like it's done on IA-32. 3370 // TODO(X64): Optimize this like it's done on IA-32.
3351 ASSERT(args->length() == 1); 3371 ASSERT(args->length() == 1);
3352 Load(args->at(0)); // Load the object. 3372 Load(args->at(0)); // Load the object.
3353 Result result = frame_->CallRuntime(Runtime::kClassOf, 1); 3373 Result result = frame_->CallRuntime(Runtime::kClassOf, 1);
(...skipping 2127 matching lines...) Expand 10 before | Expand all | Expand 10 after
5481 frame_->Push(Handle<Object>(answer_object)); 5501 frame_->Push(Handle<Object>(answer_object));
5482 return true; 5502 return true;
5483 } 5503 }
5484 5504
5485 5505
5486 // End of CodeGenerator implementation. 5506 // End of CodeGenerator implementation.
5487 5507
5488 void UnarySubStub::Generate(MacroAssembler* masm) { 5508 void UnarySubStub::Generate(MacroAssembler* masm) {
5489 Label slow; 5509 Label slow;
5490 Label done; 5510 Label done;
5491 Label try_float;
5492 5511
5493 // Check whether the value is a smi. 5512 // Check whether the value is a smi.
5494 __ testl(rax, Immediate(kSmiTagMask)); 5513 __ testl(rax, Immediate(kSmiTagMask));
5495 // TODO(X64): Add inline code that handles floats, as on ia32 platform. 5514 // TODO(X64): Add inline code that handles floats, as on ia32 platform.
5496 __ j(not_zero, &slow); 5515 __ j(not_zero, &slow);
5497 5516 // Enter runtime system if the value of the smi is zero
5498 // Enter runtime system if the value of the expression is zero
5499 // to make sure that we switch between 0 and -0. 5517 // to make sure that we switch between 0 and -0.
5500 __ testq(rax, rax); 5518 // Also enter it if the value of the smi is Smi::kMinValue
5519 __ testl(rax, Immediate(0x7FFFFFFE));
5501 __ j(zero, &slow); 5520 __ j(zero, &slow);
5502 5521 __ neg(rax);
5503 // The value of the expression is a smi that is not zero. Try 5522 __ jmp(&done);
5504 // optimistic subtraction '0 - value'.
5505 __ movq(rdx, rax);
5506 __ xor_(rax, rax);
5507 __ subl(rax, rdx);
5508 __ j(no_overflow, &done);
5509 // Restore rax and enter runtime system.
5510 __ movq(rax, rdx);
5511
5512 // Enter runtime system. 5523 // Enter runtime system.
5513 __ bind(&slow); 5524 __ bind(&slow);
5514 __ pop(rcx); // pop return address 5525 __ pop(rcx); // pop return address
5515 __ push(rax); 5526 __ push(rax);
5516 __ push(rcx); // push return address 5527 __ push(rcx); // push return address
5517 __ InvokeBuiltin(Builtins::UNARY_MINUS, JUMP_FUNCTION); 5528 __ InvokeBuiltin(Builtins::UNARY_MINUS, JUMP_FUNCTION);
5518 5529
5519 __ bind(&done); 5530 __ bind(&done);
5520 __ StubReturn(1); 5531 __ StubReturn(1);
5521 } 5532 }
(...skipping 1305 matching lines...) Expand 10 before | Expand all | Expand 10 after
6827 int CompareStub::MinorKey() { 6838 int CompareStub::MinorKey() {
6828 // Encode the two parameters in a unique 16 bit value. 6839 // Encode the two parameters in a unique 16 bit value.
6829 ASSERT(static_cast<unsigned>(cc_) < (1 << 15)); 6840 ASSERT(static_cast<unsigned>(cc_) < (1 << 15));
6830 return (static_cast<unsigned>(cc_) << 1) | (strict_ ? 1 : 0); 6841 return (static_cast<unsigned>(cc_) << 1) | (strict_ ? 1 : 0);
6831 } 6842 }
6832 6843
6833 6844
6834 #undef __ 6845 #undef __
6835 6846
6836 } } // namespace v8::internal 6847 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698