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

Side by Side Diff: src/hydrogen-instructions.cc

Issue 23654041: Ensure constant truncation is only done when it is safe. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 3 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/hydrogen-instructions.h ('k') | 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 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 2557 matching lines...) Expand 10 before | Expand all | Expand 10 after
2568 if (has_int32_value_) { 2568 if (has_int32_value_) {
2569 res = new(zone) HConstant(int32_value_, 2569 res = new(zone) HConstant(int32_value_,
2570 Representation::Integer32(), 2570 Representation::Integer32(),
2571 is_not_in_new_space_, 2571 is_not_in_new_space_,
2572 handle_); 2572 handle_);
2573 } else if (has_double_value_) { 2573 } else if (has_double_value_) {
2574 res = new(zone) HConstant(DoubleToInt32(double_value_), 2574 res = new(zone) HConstant(DoubleToInt32(double_value_),
2575 Representation::Integer32(), 2575 Representation::Integer32(),
2576 is_not_in_new_space_, 2576 is_not_in_new_space_,
2577 handle_); 2577 handle_);
2578 } else {
2579 ASSERT(!HasNumberValue());
2580 Maybe<HConstant*> number = CopyToTruncatedNumber(zone);
2581 if (number.has_value) return number.value->CopyToTruncatedInt32(zone);
2582 } 2578 }
2583 return Maybe<HConstant*>(res != NULL, res); 2579 return Maybe<HConstant*>(res != NULL, res);
2584 } 2580 }
2585 2581
2586 2582
2587 Maybe<HConstant*> HConstant::CopyToTruncatedNumber(Zone* zone) { 2583 Maybe<HConstant*> HConstant::CopyToTruncatedNumberAndAdd(
2584 Zone* zone, HGraphBuilder* builder) {
Michael Starzinger 2013/09/17 12:10:13 I don't like passing around the HGraphBuilder into
2588 HConstant* res = NULL; 2585 HConstant* res = NULL;
2589 Handle<Object> handle = this->handle(zone->isolate()); 2586 Handle<Object> handle = this->handle(zone->isolate());
2590 if (handle->IsBoolean()) { 2587 if (handle->IsBoolean()) {
2591 res = handle->BooleanValue() ? 2588 res = handle->BooleanValue()
2592 new(zone) HConstant(1) : new(zone) HConstant(0); 2589 ? builder->graph()->GetConstant1()
2590 : builder->graph()->GetConstant0();
2593 } else if (handle->IsUndefined()) { 2591 } else if (handle->IsUndefined()) {
2594 res = new(zone) HConstant(OS::nan_value()); 2592 res = builder->Add<HConstant>(OS::nan_value());
2595 } else if (handle->IsNull()) { 2593 } else if (handle->IsNull()) {
2596 res = new(zone) HConstant(0); 2594 res = builder->graph()->GetConstant0();
2597 } 2595 }
2598 return Maybe<HConstant*>(res != NULL, res); 2596 return Maybe<HConstant*>(res != NULL, res);
2599 } 2597 }
2600 2598
2601 2599
2602 void HConstant::PrintDataTo(StringStream* stream) { 2600 void HConstant::PrintDataTo(StringStream* stream) {
2603 if (has_int32_value_) { 2601 if (has_int32_value_) {
2604 stream->Add("%d ", int32_value_); 2602 stream->Add("%d ", int32_value_);
2605 } else if (has_double_value_) { 2603 } else if (has_double_value_) {
2606 stream->Add("%f ", FmtElm(double_value_)); 2604 stream->Add("%f ", FmtElm(double_value_));
(...skipping 1633 matching lines...) Expand 10 before | Expand all | Expand 10 after
4240 break; 4238 break;
4241 case kExternalMemory: 4239 case kExternalMemory:
4242 stream->Add("[external-memory]"); 4240 stream->Add("[external-memory]");
4243 break; 4241 break;
4244 } 4242 }
4245 4243
4246 stream->Add("@%d", offset()); 4244 stream->Add("@%d", offset());
4247 } 4245 }
4248 4246
4249 } } // namespace v8::internal 4247 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen-instructions.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698