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

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

Issue 19798002: Faster to number conversion (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebase Created 7 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 | « src/hydrogen-instructions.h ('k') | src/hydrogen-representation-changes.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 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 2292 matching lines...) Expand 10 before | Expand all | Expand 10 after
2303 unique_id_, 2303 unique_id_,
2304 r, 2304 r,
2305 type_from_value_, 2305 type_from_value_,
2306 is_internalized_string_, 2306 is_internalized_string_,
2307 is_not_in_new_space_, 2307 is_not_in_new_space_,
2308 is_cell_, 2308 is_cell_,
2309 boolean_value_); 2309 boolean_value_);
2310 } 2310 }
2311 2311
2312 2312
2313 HConstant* HConstant::CopyToTruncatedInt32(Zone* zone) const { 2313 Maybe<HConstant*> HConstant::CopyToTruncatedInt32(Zone* zone) {
2314 HConstant* res = NULL;
2314 if (has_int32_value_) { 2315 if (has_int32_value_) {
2315 return new(zone) HConstant(int32_value_, 2316 res = new(zone) HConstant(int32_value_,
2316 Representation::Integer32(), 2317 Representation::Integer32(),
2317 is_not_in_new_space_, 2318 is_not_in_new_space_,
2318 handle_); 2319 handle_);
2320 } else if (has_double_value_) {
2321 res = new(zone) HConstant(DoubleToInt32(double_value_),
2322 Representation::Integer32(),
2323 is_not_in_new_space_,
2324 handle_);
2325 } else {
2326 ASSERT(!HasNumberValue());
2327 Maybe<HConstant*> number = CopyToTruncatedNumber(zone);
2328 if (number.has_value) return number.value->CopyToTruncatedInt32(zone);
2319 } 2329 }
2320 if (has_double_value_) { 2330 return Maybe<HConstant*>(res != NULL, res);
2321 return new(zone) HConstant(DoubleToInt32(double_value_),
2322 Representation::Integer32(),
2323 is_not_in_new_space_,
2324 handle_);
2325 }
2326 return NULL;
2327 } 2331 }
2328 2332
2329 2333
2334 Maybe<HConstant*> HConstant::CopyToTruncatedNumber(Zone* zone) {
2335 HConstant* res = NULL;
2336 if (handle()->IsBoolean()) {
2337 res = handle()->BooleanValue() ?
2338 new(zone) HConstant(1) : new(zone) HConstant(0);
2339 } else if (handle()->IsUndefined()) {
2340 res = new(zone) HConstant(OS::nan_value());
2341 } else if (handle()->IsNull()) {
2342 res = new(zone) HConstant(0);
2343 }
2344 return Maybe<HConstant*>(res != NULL, res);
2345 }
2346
2347
2330 void HConstant::PrintDataTo(StringStream* stream) { 2348 void HConstant::PrintDataTo(StringStream* stream) {
2331 if (has_int32_value_) { 2349 if (has_int32_value_) {
2332 stream->Add("%d ", int32_value_); 2350 stream->Add("%d ", int32_value_);
2333 } else if (has_double_value_) { 2351 } else if (has_double_value_) {
2334 stream->Add("%f ", FmtElm(double_value_)); 2352 stream->Add("%f ", FmtElm(double_value_));
2335 } else { 2353 } else {
2336 handle()->ShortPrint(stream); 2354 handle()->ShortPrint(stream);
2337 } 2355 }
2338 } 2356 }
2339 2357
(...skipping 1640 matching lines...) Expand 10 before | Expand all | Expand 10 after
3980 case kBackingStore: 3998 case kBackingStore:
3981 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); 3999 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString());
3982 stream->Add("[backing-store]"); 4000 stream->Add("[backing-store]");
3983 break; 4001 break;
3984 } 4002 }
3985 4003
3986 stream->Add("@%d", offset()); 4004 stream->Add("@%d", offset());
3987 } 4005 }
3988 4006
3989 } } // namespace v8::internal 4007 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen-instructions.h ('k') | src/hydrogen-representation-changes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698