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

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

Issue 146077: Removed static type inference and add a dynamic test for string addition. (Closed)
Patch Set: And it lints too. Created 11 years, 6 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
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 2320 matching lines...) Expand 10 before | Expand all | Expand 10 after
2331 flags = ((loop_nesting() > 0) && type->IsLikelySmi()) 2331 flags = ((loop_nesting() > 0) && type->IsLikelySmi())
2332 ? SMI_CODE_INLINED 2332 ? SMI_CODE_INLINED
2333 : SMI_CODE_IN_STUB; 2333 : SMI_CODE_IN_STUB;
2334 break; 2334 break;
2335 } 2335 }
2336 2336
2337 Result right = frame_->Pop(); 2337 Result right = frame_->Pop();
2338 Result left = frame_->Pop(); 2338 Result left = frame_->Pop();
2339 2339
2340 if (op == Token::ADD) { 2340 if (op == Token::ADD) {
2341 bool left_is_string = left.static_type().is_jsstring(); 2341 bool left_is_string = left.is_constant() && left.handle()->IsString();
2342 bool right_is_string = right.static_type().is_jsstring(); 2342 bool right_is_string = right.is_constant() && right.handle()->IsString();
2343 if (left_is_string || right_is_string) { 2343 if (left_is_string || right_is_string) {
2344 frame_->Push(&left); 2344 frame_->Push(&left);
2345 frame_->Push(&right); 2345 frame_->Push(&right);
2346 Result answer; 2346 Result answer;
2347 if (left_is_string) { 2347 if (left_is_string) {
2348 if (right_is_string) { 2348 if (right_is_string) {
2349 // TODO(lrn): if (left.is_constant() && right.is_constant()) 2349 // TODO(lrn): if both are constant strings
2350 // -- do a compile time cons, if allocation during codegen is allowed. 2350 // -- do a compile time cons, if allocation during codegen is allowed.
2351 answer = frame_->CallRuntime(Runtime::kStringAdd, 2); 2351 answer = frame_->CallRuntime(Runtime::kStringAdd, 2);
2352 } else { 2352 } else {
2353 answer = 2353 answer =
2354 frame_->InvokeBuiltin(Builtins::STRING_ADD_LEFT, CALL_FUNCTION, 2); 2354 frame_->InvokeBuiltin(Builtins::STRING_ADD_LEFT, CALL_FUNCTION, 2);
2355 } 2355 }
2356 } else if (right_is_string) { 2356 } else if (right_is_string) {
2357 answer = 2357 answer =
2358 frame_->InvokeBuiltin(Builtins::STRING_ADD_RIGHT, CALL_FUNCTION, 2); 2358 frame_->InvokeBuiltin(Builtins::STRING_ADD_RIGHT, CALL_FUNCTION, 2);
2359 } 2359 }
2360 answer.set_static_type(StaticType::jsstring());
2361 frame_->Push(&answer); 2360 frame_->Push(&answer);
2362 return; 2361 return;
2363 } 2362 }
2364 // Neither operand is known to be a string. 2363 // Neither operand is known to be a string.
2365 } 2364 }
2366 2365
2367 bool left_is_smi = left.is_constant() && left.handle()->IsSmi(); 2366 bool left_is_smi = left.is_constant() && left.handle()->IsSmi();
2368 bool left_is_non_smi = left.is_constant() && !left.handle()->IsSmi(); 2367 bool left_is_non_smi = left.is_constant() && !left.handle()->IsSmi();
2369 bool right_is_smi = right.is_constant() && right.handle()->IsSmi(); 2368 bool right_is_smi = right.is_constant() && right.handle()->IsSmi();
2370 bool right_is_non_smi = right.is_constant() && !right.handle()->IsSmi(); 2369 bool right_is_non_smi = right.is_constant() && !right.handle()->IsSmi();
(...skipping 1619 matching lines...) Expand 10 before | Expand all | Expand 10 after
3990 break; 3989 break;
3991 default: 3990 default:
3992 UNREACHABLE(); 3991 UNREACHABLE();
3993 } 3992 }
3994 } 3993 }
3995 3994
3996 3995
3997 #undef __ 3996 #undef __
3998 3997
3999 } } // namespace v8::internal 3998 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698