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

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

Issue 8373029: [hydrogen] optimize switch with string clauses (Closed) Base URL: gh:v8/v8@master
Patch Set: mips: CompareGenericAndBranch Created 9 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
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 } 223 }
224 224
225 225
226 void LIsObjectAndBranch::PrintDataTo(StringStream* stream) { 226 void LIsObjectAndBranch::PrintDataTo(StringStream* stream) {
227 stream->Add("if is_object("); 227 stream->Add("if is_object(");
228 InputAt(0)->PrintTo(stream); 228 InputAt(0)->PrintTo(stream);
229 stream->Add(") then B%d else B%d", true_block_id(), false_block_id()); 229 stream->Add(") then B%d else B%d", true_block_id(), false_block_id());
230 } 230 }
231 231
232 232
233 void LIsStringAndBranch::PrintDataTo(StringStream* stream) {
234 stream->Add("if is_string(");
235 InputAt(0)->PrintTo(stream);
236 stream->Add(") then B%d else B%d", true_block_id(), false_block_id());
237 }
238
239
233 void LIsSmiAndBranch::PrintDataTo(StringStream* stream) { 240 void LIsSmiAndBranch::PrintDataTo(StringStream* stream) {
234 stream->Add("if is_smi("); 241 stream->Add("if is_smi(");
235 InputAt(0)->PrintTo(stream); 242 InputAt(0)->PrintTo(stream);
236 stream->Add(") then B%d else B%d", true_block_id(), false_block_id()); 243 stream->Add(") then B%d else B%d", true_block_id(), false_block_id());
237 } 244 }
238 245
239 246
240 void LIsUndetectableAndBranch::PrintDataTo(StringStream* stream) { 247 void LIsUndetectableAndBranch::PrintDataTo(StringStream* stream) {
241 stream->Add("if is_undetectable("); 248 stream->Add("if is_undetectable(");
242 InputAt(0)->PrintTo(stream); 249 InputAt(0)->PrintTo(stream);
243 stream->Add(") then B%d else B%d", true_block_id(), false_block_id()); 250 stream->Add(") then B%d else B%d", true_block_id(), false_block_id());
244 } 251 }
245 252
246 253
254 void LCompareGenericAndBranch::PrintDataTo(StringStream* stream) {
255 stream->Add("if compare_generic(");
256 InputAt(0)->PrintTo(stream);
257 InputAt(1)->PrintTo(stream);
258 stream->Add(") then B%d else B%d", true_block_id(), false_block_id());
259 }
260
261
247 void LHasInstanceTypeAndBranch::PrintDataTo(StringStream* stream) { 262 void LHasInstanceTypeAndBranch::PrintDataTo(StringStream* stream) {
248 stream->Add("if has_instance_type("); 263 stream->Add("if has_instance_type(");
249 InputAt(0)->PrintTo(stream); 264 InputAt(0)->PrintTo(stream);
250 stream->Add(") then B%d else B%d", true_block_id(), false_block_id()); 265 stream->Add(") then B%d else B%d", true_block_id(), false_block_id());
251 } 266 }
252 267
253 268
254 void LHasCachedArrayIndexAndBranch::PrintDataTo(StringStream* stream) { 269 void LHasCachedArrayIndexAndBranch::PrintDataTo(StringStream* stream) {
255 stream->Add("if has_cached_array_index("); 270 stream->Add("if has_cached_array_index(");
256 InputAt(0)->PrintTo(stream); 271 InputAt(0)->PrintTo(stream);
(...skipping 1143 matching lines...) Expand 10 before | Expand all | Expand 10 after
1400 CAN_DEOPTIMIZE_EAGERLY); 1415 CAN_DEOPTIMIZE_EAGERLY);
1401 } 1416 }
1402 1417
1403 1418
1404 LInstruction* LChunkBuilder::DoCompareGeneric(HCompareGeneric* instr) { 1419 LInstruction* LChunkBuilder::DoCompareGeneric(HCompareGeneric* instr) {
1405 ASSERT(instr->left()->representation().IsTagged()); 1420 ASSERT(instr->left()->representation().IsTagged());
1406 ASSERT(instr->right()->representation().IsTagged()); 1421 ASSERT(instr->right()->representation().IsTagged());
1407 LOperand* left = UseFixed(instr->left(), rdx); 1422 LOperand* left = UseFixed(instr->left(), rdx);
1408 LOperand* right = UseFixed(instr->right(), rax); 1423 LOperand* right = UseFixed(instr->right(), rax);
1409 LCmpT* result = new LCmpT(left, right); 1424 LCmpT* result = new LCmpT(left, right);
1410 return MarkAsCall(DefineFixed(result, rax), instr); 1425 return AssignEnvironment(MarkAsCall(DefineFixed(result, rax), instr));
1411 } 1426 }
1412 1427
1413 1428
1414 LInstruction* LChunkBuilder::DoCompareIDAndBranch( 1429 LInstruction* LChunkBuilder::DoCompareIDAndBranch(
1415 HCompareIDAndBranch* instr) { 1430 HCompareIDAndBranch* instr) {
1416 Representation r = instr->GetInputRepresentation(); 1431 Representation r = instr->GetInputRepresentation();
1417 if (r.IsInteger32()) { 1432 if (r.IsInteger32()) {
1418 ASSERT(instr->left()->representation().IsInteger32()); 1433 ASSERT(instr->left()->representation().IsInteger32());
1419 ASSERT(instr->right()->representation().IsInteger32()); 1434 ASSERT(instr->right()->representation().IsInteger32());
1420 LOperand* left = UseRegisterOrConstantAtStart(instr->left()); 1435 LOperand* left = UseRegisterOrConstantAtStart(instr->left());
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1458 return new LIsNilAndBranch(UseRegisterAtStart(instr->value()), temp); 1473 return new LIsNilAndBranch(UseRegisterAtStart(instr->value()), temp);
1459 } 1474 }
1460 1475
1461 1476
1462 LInstruction* LChunkBuilder::DoIsObjectAndBranch(HIsObjectAndBranch* instr) { 1477 LInstruction* LChunkBuilder::DoIsObjectAndBranch(HIsObjectAndBranch* instr) {
1463 ASSERT(instr->value()->representation().IsTagged()); 1478 ASSERT(instr->value()->representation().IsTagged());
1464 return new LIsObjectAndBranch(UseRegisterAtStart(instr->value())); 1479 return new LIsObjectAndBranch(UseRegisterAtStart(instr->value()));
1465 } 1480 }
1466 1481
1467 1482
1483 LInstruction* LChunkBuilder::DoIsStringAndBranch(HIsStringAndBranch* instr) {
1484 ASSERT(instr->value()->representation().IsTagged());
1485 return new LIsStringAndBranch(UseRegisterAtStart(instr->value()));
1486 }
1487
1488
1468 LInstruction* LChunkBuilder::DoIsSmiAndBranch(HIsSmiAndBranch* instr) { 1489 LInstruction* LChunkBuilder::DoIsSmiAndBranch(HIsSmiAndBranch* instr) {
1469 ASSERT(instr->value()->representation().IsTagged()); 1490 ASSERT(instr->value()->representation().IsTagged());
1470 return new LIsSmiAndBranch(Use(instr->value())); 1491 return new LIsSmiAndBranch(Use(instr->value()));
1471 } 1492 }
1472 1493
1473 1494
1474 LInstruction* LChunkBuilder::DoIsUndetectableAndBranch( 1495 LInstruction* LChunkBuilder::DoIsUndetectableAndBranch(
1475 HIsUndetectableAndBranch* instr) { 1496 HIsUndetectableAndBranch* instr) {
1476 ASSERT(instr->value()->representation().IsTagged()); 1497 ASSERT(instr->value()->representation().IsTagged());
1477 return new LIsUndetectableAndBranch(UseRegisterAtStart(instr->value()), 1498 return new LIsUndetectableAndBranch(UseRegisterAtStart(instr->value()),
1478 TempRegister()); 1499 TempRegister());
1479 } 1500 }
1480 1501
1481 1502
1503 LInstruction* LChunkBuilder::DoCompareGenericAndBranch(
1504 HCompareGenericAndBranch* instr) {
1505
1506 ASSERT(instr->left()->representation().IsTagged());
1507 ASSERT(instr->right()->representation().IsTagged());
1508 LOperand* left = UseFixed(instr->left(), rdx);
1509 LOperand* right = UseFixed(instr->right(), rax);
1510 LCompareGenericAndBranch* result = new LCompareGenericAndBranch(left, right);
1511
1512 return AssignEnvironment(MarkAsCall(result, instr));
1513 }
1514
1515
1482 LInstruction* LChunkBuilder::DoHasInstanceTypeAndBranch( 1516 LInstruction* LChunkBuilder::DoHasInstanceTypeAndBranch(
1483 HHasInstanceTypeAndBranch* instr) { 1517 HHasInstanceTypeAndBranch* instr) {
1484 ASSERT(instr->value()->representation().IsTagged()); 1518 ASSERT(instr->value()->representation().IsTagged());
1485 return new LHasInstanceTypeAndBranch(UseRegisterAtStart(instr->value())); 1519 return new LHasInstanceTypeAndBranch(UseRegisterAtStart(instr->value()));
1486 } 1520 }
1487 1521
1488 1522
1489 LInstruction* LChunkBuilder::DoGetCachedArrayIndex( 1523 LInstruction* LChunkBuilder::DoGetCachedArrayIndex(
1490 HGetCachedArrayIndex* instr) { 1524 HGetCachedArrayIndex* instr) {
1491 ASSERT(instr->value()->representation().IsTagged()); 1525 ASSERT(instr->value()->representation().IsTagged());
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after
2209 LOperand* key = UseOrConstantAtStart(instr->key()); 2243 LOperand* key = UseOrConstantAtStart(instr->key());
2210 LOperand* object = UseOrConstantAtStart(instr->object()); 2244 LOperand* object = UseOrConstantAtStart(instr->object());
2211 LIn* result = new LIn(key, object); 2245 LIn* result = new LIn(key, object);
2212 return MarkAsCall(DefineFixed(result, rax), instr); 2246 return MarkAsCall(DefineFixed(result, rax), instr);
2213 } 2247 }
2214 2248
2215 2249
2216 } } // namespace v8::internal 2250 } } // namespace v8::internal
2217 2251
2218 #endif // V8_TARGET_ARCH_X64 2252 #endif // V8_TARGET_ARCH_X64
OLDNEW
« src/ia32/lithium-ia32.cc ('K') | « src/x64/lithium-x64.h ('k') | test/mjsunit/switch.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698