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

Side by Side Diff: src/hydrogen.cc

Issue 68723002: Implement Math.random() purely in JavaScript. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Comments only Created 7 years, 1 month 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/heap.cc ('k') | src/hydrogen-instructions.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 7313 matching lines...) Expand 10 before | Expand all | Expand 10 after
7324 } 7324 }
7325 } 7325 }
7326 7326
7327 if (result == NULL) { 7327 if (result == NULL) {
7328 result = NewUncasted<HPower>(left, right); 7328 result = NewUncasted<HPower>(left, right);
7329 } 7329 }
7330 ast_context()->ReturnInstruction(result, expr->id()); 7330 ast_context()->ReturnInstruction(result, expr->id());
7331 return true; 7331 return true;
7332 } 7332 }
7333 break; 7333 break;
7334 case kMathRandom:
7335 if (argument_count == 1 && check_type == RECEIVER_MAP_CHECK) {
7336 AddCheckConstantFunction(expr->holder(), receiver, receiver_map);
7337 Drop(1); // Receiver.
7338 HGlobalObject* global_object = Add<HGlobalObject>();
7339 HRandom* result = New<HRandom>(global_object);
7340 ast_context()->ReturnInstruction(result, expr->id());
7341 return true;
7342 }
7343 break;
7344 case kMathMax: 7334 case kMathMax:
7345 case kMathMin: 7335 case kMathMin:
7346 if (argument_count == 3 && check_type == RECEIVER_MAP_CHECK) { 7336 if (argument_count == 3 && check_type == RECEIVER_MAP_CHECK) {
7347 AddCheckConstantFunction(expr->holder(), receiver, receiver_map); 7337 AddCheckConstantFunction(expr->holder(), receiver, receiver_map);
7348 HValue* right = Pop(); 7338 HValue* right = Pop();
7349 HValue* left = Pop(); 7339 HValue* left = Pop();
7350 Drop(1); // Receiver. 7340 Drop(1); // Receiver.
7351 HMathMinMax::Operation op = (id == kMathMin) ? HMathMinMax::kMathMin 7341 HMathMinMax::Operation op = (id == kMathMin) ? HMathMinMax::kMathMin
7352 : HMathMinMax::kMathMax; 7342 : HMathMinMax::kMathMax;
7353 HInstruction* result = NewUncasted<HMathMinMax>(left, right, op); 7343 HInstruction* result = NewUncasted<HMathMinMax>(left, right, op);
(...skipping 2264 matching lines...) Expand 10 before | Expand all | Expand 10 after
9618 return ast_context()->ReturnControl(result, call->id()); 9608 return ast_context()->ReturnControl(result, call->id());
9619 } 9609 }
9620 9610
9621 9611
9622 void HOptimizedGraphBuilder::GenerateLog(CallRuntime* call) { 9612 void HOptimizedGraphBuilder::GenerateLog(CallRuntime* call) {
9623 // %_Log is ignored in optimized code. 9613 // %_Log is ignored in optimized code.
9624 return ast_context()->ReturnValue(graph()->GetConstantUndefined()); 9614 return ast_context()->ReturnValue(graph()->GetConstantUndefined());
9625 } 9615 }
9626 9616
9627 9617
9628 // Fast support for Math.random().
9629 void HOptimizedGraphBuilder::GenerateRandomHeapNumber(CallRuntime* call) {
9630 HGlobalObject* global_object = Add<HGlobalObject>();
9631 HRandom* result = New<HRandom>(global_object);
9632 return ast_context()->ReturnInstruction(result, call->id());
9633 }
9634
9635
9636 // Fast support for StringAdd. 9618 // Fast support for StringAdd.
9637 void HOptimizedGraphBuilder::GenerateStringAdd(CallRuntime* call) { 9619 void HOptimizedGraphBuilder::GenerateStringAdd(CallRuntime* call) {
9638 ASSERT_EQ(2, call->arguments()->length()); 9620 ASSERT_EQ(2, call->arguments()->length());
9639 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); 9621 CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
9640 CHECK_ALIVE(VisitForValue(call->arguments()->at(1))); 9622 CHECK_ALIVE(VisitForValue(call->arguments()->at(1)));
9641 HValue* right = Pop(); 9623 HValue* right = Pop();
9642 HValue* left = Pop(); 9624 HValue* left = Pop();
9643 HInstruction* result = New<HStringAdd>(left, right, STRING_ADD_CHECK_BOTH); 9625 HInstruction* result = New<HStringAdd>(left, right, STRING_ADD_CHECK_BOTH);
9644 return ast_context()->ReturnInstruction(result, call->id()); 9626 return ast_context()->ReturnInstruction(result, call->id());
9645 } 9627 }
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after
10418 if (ShouldProduceTraceOutput()) { 10400 if (ShouldProduceTraceOutput()) {
10419 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 10401 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
10420 } 10402 }
10421 10403
10422 #ifdef DEBUG 10404 #ifdef DEBUG
10423 graph_->Verify(false); // No full verify. 10405 graph_->Verify(false); // No full verify.
10424 #endif 10406 #endif
10425 } 10407 }
10426 10408
10427 } } // namespace v8::internal 10409 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap.cc ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698