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

Side by Side Diff: src/ia32/lithium-ia32.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(1)->PrintTo(stream);
257 InputAt(2)->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 1182 matching lines...) Expand 10 before | Expand all | Expand 10 after
1439 } 1454 }
1440 1455
1441 1456
1442 LInstruction* LChunkBuilder::DoCompareGeneric(HCompareGeneric* instr) { 1457 LInstruction* LChunkBuilder::DoCompareGeneric(HCompareGeneric* instr) {
1443 ASSERT(instr->left()->representation().IsTagged()); 1458 ASSERT(instr->left()->representation().IsTagged());
1444 ASSERT(instr->right()->representation().IsTagged()); 1459 ASSERT(instr->right()->representation().IsTagged());
1445 LOperand* context = UseFixed(instr->context(), esi); 1460 LOperand* context = UseFixed(instr->context(), esi);
1446 LOperand* left = UseFixed(instr->left(), edx); 1461 LOperand* left = UseFixed(instr->left(), edx);
1447 LOperand* right = UseFixed(instr->right(), eax); 1462 LOperand* right = UseFixed(instr->right(), eax);
1448 LCmpT* result = new LCmpT(context, left, right); 1463 LCmpT* result = new LCmpT(context, left, right);
1449 return MarkAsCall(DefineFixed(result, eax), instr); 1464 return AssignEnvironment(MarkAsCall(DefineFixed(result, eax), instr));
fschneider 2011/11/01 09:26:19 MarkAsCall should already assign environments if n
indutny 2011/11/01 09:31:07 It was segfaulting w/o that
1450 } 1465 }
1451 1466
1452 1467
1453 LInstruction* LChunkBuilder::DoCompareIDAndBranch( 1468 LInstruction* LChunkBuilder::DoCompareIDAndBranch(
1454 HCompareIDAndBranch* instr) { 1469 HCompareIDAndBranch* instr) {
1455 Representation r = instr->GetInputRepresentation(); 1470 Representation r = instr->GetInputRepresentation();
1456 if (r.IsInteger32()) { 1471 if (r.IsInteger32()) {
1457 ASSERT(instr->left()->representation().IsInteger32()); 1472 ASSERT(instr->left()->representation().IsInteger32());
1458 ASSERT(instr->right()->representation().IsInteger32()); 1473 ASSERT(instr->right()->representation().IsInteger32());
1459 LOperand* left = UseRegisterOrConstantAtStart(instr->left()); 1474 LOperand* left = UseRegisterOrConstantAtStart(instr->left());
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1498 } 1513 }
1499 1514
1500 1515
1501 LInstruction* LChunkBuilder::DoIsObjectAndBranch(HIsObjectAndBranch* instr) { 1516 LInstruction* LChunkBuilder::DoIsObjectAndBranch(HIsObjectAndBranch* instr) {
1502 ASSERT(instr->value()->representation().IsTagged()); 1517 ASSERT(instr->value()->representation().IsTagged());
1503 LOperand* temp = TempRegister(); 1518 LOperand* temp = TempRegister();
1504 return new LIsObjectAndBranch(UseRegister(instr->value()), temp); 1519 return new LIsObjectAndBranch(UseRegister(instr->value()), temp);
1505 } 1520 }
1506 1521
1507 1522
1523 LInstruction* LChunkBuilder::DoIsStringAndBranch(HIsStringAndBranch* instr) {
1524 ASSERT(instr->value()->representation().IsTagged());
1525 LOperand* temp = TempRegister();
1526 return new LIsStringAndBranch(UseRegister(instr->value()), temp);
1527 }
1528
1529
1508 LInstruction* LChunkBuilder::DoIsSmiAndBranch(HIsSmiAndBranch* instr) { 1530 LInstruction* LChunkBuilder::DoIsSmiAndBranch(HIsSmiAndBranch* instr) {
1509 ASSERT(instr->value()->representation().IsTagged()); 1531 ASSERT(instr->value()->representation().IsTagged());
1510 return new LIsSmiAndBranch(Use(instr->value())); 1532 return new LIsSmiAndBranch(Use(instr->value()));
1511 } 1533 }
1512 1534
1513 1535
1514 LInstruction* LChunkBuilder::DoIsUndetectableAndBranch( 1536 LInstruction* LChunkBuilder::DoIsUndetectableAndBranch(
1515 HIsUndetectableAndBranch* instr) { 1537 HIsUndetectableAndBranch* instr) {
1516 ASSERT(instr ->value()->representation().IsTagged()); 1538 ASSERT(instr ->value()->representation().IsTagged());
1517 return new LIsUndetectableAndBranch(UseRegisterAtStart(instr->value()), 1539 return new LIsUndetectableAndBranch(UseRegisterAtStart(instr->value()),
1518 TempRegister()); 1540 TempRegister());
1519 } 1541 }
1520 1542
1521 1543
1544 LInstruction* LChunkBuilder::DoCompareGenericAndBranch(
1545 HCompareGenericAndBranch* instr) {
1546 ASSERT(instr->left()->representation().IsTagged());
1547 ASSERT(instr->right()->representation().IsTagged());
1548 LOperand* context = UseFixed(instr->context(), esi);
1549 LOperand* left = UseFixed(instr->left(), edx);
1550 LOperand* right = UseFixed(instr->right(), eax);
1551
1552 LCompareGenericAndBranch* result = new
1553 LCompareGenericAndBranch(context, left, right);
1554
1555 return AssignEnvironment(MarkAsCall(result, instr));
1556 }
1557
1558
1522 LInstruction* LChunkBuilder::DoHasInstanceTypeAndBranch( 1559 LInstruction* LChunkBuilder::DoHasInstanceTypeAndBranch(
1523 HHasInstanceTypeAndBranch* instr) { 1560 HHasInstanceTypeAndBranch* instr) {
1524 ASSERT(instr->value()->representation().IsTagged()); 1561 ASSERT(instr->value()->representation().IsTagged());
1525 return new LHasInstanceTypeAndBranch(UseRegisterAtStart(instr->value()), 1562 return new LHasInstanceTypeAndBranch(UseRegisterAtStart(instr->value()),
1526 TempRegister()); 1563 TempRegister());
1527 } 1564 }
1528 1565
1529 1566
1530 LInstruction* LChunkBuilder::DoGetCachedArrayIndex( 1567 LInstruction* LChunkBuilder::DoGetCachedArrayIndex(
1531 HGetCachedArrayIndex* instr) { 1568 HGetCachedArrayIndex* instr) {
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after
2310 LOperand* key = UseOrConstantAtStart(instr->key()); 2347 LOperand* key = UseOrConstantAtStart(instr->key());
2311 LOperand* object = UseOrConstantAtStart(instr->object()); 2348 LOperand* object = UseOrConstantAtStart(instr->object());
2312 LIn* result = new LIn(context, key, object); 2349 LIn* result = new LIn(context, key, object);
2313 return MarkAsCall(DefineFixed(result, eax), instr); 2350 return MarkAsCall(DefineFixed(result, eax), instr);
2314 } 2351 }
2315 2352
2316 2353
2317 } } // namespace v8::internal 2354 } } // namespace v8::internal
2318 2355
2319 #endif // V8_TARGET_ARCH_IA32 2356 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« src/hydrogen.cc ('K') | « src/ia32/lithium-ia32.h ('k') | src/mips/lithium-codegen-mips.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698