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

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

Issue 6580038: [Isolates] Merge from bleeding_edge, revisions 5934-6100. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: '' Created 9 years, 9 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/ia32/lithium-ia32.h ('k') | src/ia32/macro-assembler-ia32.h » ('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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 199
200 200
201 void LIsNullAndBranch::PrintDataTo(StringStream* stream) const { 201 void LIsNullAndBranch::PrintDataTo(StringStream* stream) const {
202 stream->Add("if "); 202 stream->Add("if ");
203 input()->PrintTo(stream); 203 input()->PrintTo(stream);
204 stream->Add(is_strict() ? " === null" : " == null"); 204 stream->Add(is_strict() ? " === null" : " == null");
205 stream->Add(" then B%d else B%d", true_block_id(), false_block_id()); 205 stream->Add(" then B%d else B%d", true_block_id(), false_block_id());
206 } 206 }
207 207
208 208
209 void LIsObjectAndBranch::PrintDataTo(StringStream* stream) const {
210 stream->Add("if is_object(");
211 input()->PrintTo(stream);
212 stream->Add(") then B%d else B%d", true_block_id(), false_block_id());
213 }
214
215
209 void LIsSmiAndBranch::PrintDataTo(StringStream* stream) const { 216 void LIsSmiAndBranch::PrintDataTo(StringStream* stream) const {
210 stream->Add("if is_smi("); 217 stream->Add("if is_smi(");
211 input()->PrintTo(stream); 218 input()->PrintTo(stream);
212 stream->Add(") then B%d else B%d", true_block_id(), false_block_id()); 219 stream->Add(") then B%d else B%d", true_block_id(), false_block_id());
213 } 220 }
214 221
215 222
216 void LHasInstanceTypeAndBranch::PrintDataTo(StringStream* stream) const { 223 void LHasInstanceTypeAndBranch::PrintDataTo(StringStream* stream) const {
217 stream->Add("if has_instance_type("); 224 stream->Add("if has_instance_type(");
218 input()->PrintTo(stream); 225 input()->PrintTo(stream);
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 return instructions_[index]->IsGap(); 460 return instructions_[index]->IsGap();
454 } 461 }
455 462
456 463
457 int LChunk::NearestGapPos(int index) const { 464 int LChunk::NearestGapPos(int index) const {
458 while (!IsGapAt(index)) index--; 465 while (!IsGapAt(index)) index--;
459 return index; 466 return index;
460 } 467 }
461 468
462 469
463 int LChunk::NearestNextGapPos(int index) const {
464 while (!IsGapAt(index)) index++;
465 return index;
466 }
467
468
469 void LChunk::AddGapMove(int index, LOperand* from, LOperand* to) { 470 void LChunk::AddGapMove(int index, LOperand* from, LOperand* to) {
470 GetGapAt(index)->GetOrCreateParallelMove(LGap::START)->AddMove(from, to); 471 GetGapAt(index)->GetOrCreateParallelMove(LGap::START)->AddMove(from, to);
471 } 472 }
472 473
473 474
474 class LGapNode: public ZoneObject { 475 class LGapNode: public ZoneObject {
475 public: 476 public:
476 explicit LGapNode(LOperand* operand) 477 explicit LGapNode(LOperand* operand)
477 : operand_(operand), resolved_(false), visited_id_(-1) { } 478 : operand_(operand), resolved_(false), visited_id_(-1) { }
478 479
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 874
874 875
875 LOperand* LChunkBuilder::FixedTemp(XMMRegister reg) { 876 LOperand* LChunkBuilder::FixedTemp(XMMRegister reg) {
876 LUnallocated* operand = ToUnallocated(reg); 877 LUnallocated* operand = ToUnallocated(reg);
877 allocator_->RecordTemporary(operand); 878 allocator_->RecordTemporary(operand);
878 return operand; 879 return operand;
879 } 880 }
880 881
881 882
882 LInstruction* LChunkBuilder::DoBlockEntry(HBlockEntry* instr) { 883 LInstruction* LChunkBuilder::DoBlockEntry(HBlockEntry* instr) {
883 HBasicBlock* deopt_predecessor = instr->block()->deopt_predecessor();
884 if (deopt_predecessor != NULL &&
885 deopt_predecessor->inverted()) {
886 HEnvironment* env = current_block_->last_environment();
887 HValue* value = env->Pop();
888 ASSERT(value->IsConstant());
889 Handle<Object> obj = HConstant::cast(value)->handle();
890 ASSERT(*obj == *FACTORY->true_value() || *obj == *FACTORY->false_value());
891 env->Push(*obj == *FACTORY->true_value()
892 ? current_block_->graph()->GetConstantFalse()
893 : current_block_->graph()->GetConstantTrue());
894 }
895
896 return new LLabel(instr->block()); 884 return new LLabel(instr->block());
897 } 885 }
898 886
899 887
900 LInstruction* LChunkBuilder::DoDeoptimize(HDeoptimize* instr) { 888 LInstruction* LChunkBuilder::DoDeoptimize(HDeoptimize* instr) {
901 return AssignEnvironment(new LDeoptimize); 889 return AssignEnvironment(new LDeoptimize);
902 } 890 }
903 891
904 892
905 LInstruction* LChunkBuilder::DoBit(Token::Value op, 893 LInstruction* LChunkBuilder::DoBit(Token::Value op,
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
1250 HIsNull* compare = HIsNull::cast(v); 1238 HIsNull* compare = HIsNull::cast(v);
1251 ASSERT(compare->value()->representation().IsTagged()); 1239 ASSERT(compare->value()->representation().IsTagged());
1252 1240
1253 // We only need a temp register for non-strict compare. 1241 // We only need a temp register for non-strict compare.
1254 LOperand* temp = compare->is_strict() ? NULL : TempRegister(); 1242 LOperand* temp = compare->is_strict() ? NULL : TempRegister();
1255 return new LIsNullAndBranch(UseRegisterAtStart(compare->value()), 1243 return new LIsNullAndBranch(UseRegisterAtStart(compare->value()),
1256 compare->is_strict(), 1244 compare->is_strict(),
1257 temp, 1245 temp,
1258 first_id, 1246 first_id,
1259 second_id); 1247 second_id);
1248 } else if (v->IsIsObject()) {
1249 HIsObject* compare = HIsObject::cast(v);
1250 ASSERT(compare->value()->representation().IsTagged());
1251
1252 LOperand* temp1 = TempRegister();
1253 LOperand* temp2 = TempRegister();
1254 return new LIsObjectAndBranch(UseRegisterAtStart(compare->value()),
1255 temp1,
1256 temp2,
1257 first_id,
1258 second_id);
1260 } else if (v->IsCompareJSObjectEq()) { 1259 } else if (v->IsCompareJSObjectEq()) {
1261 HCompareJSObjectEq* compare = HCompareJSObjectEq::cast(v); 1260 HCompareJSObjectEq* compare = HCompareJSObjectEq::cast(v);
1262 return new LCmpJSObjectEqAndBranch(UseRegisterAtStart(compare->left()), 1261 return new LCmpJSObjectEqAndBranch(UseRegisterAtStart(compare->left()),
1263 UseRegisterAtStart(compare->right()), 1262 UseRegisterAtStart(compare->right()),
1264 first_id, 1263 first_id,
1265 second_id); 1264 second_id);
1266 } else if (v->IsInstanceOf()) { 1265 } else if (v->IsInstanceOf()) {
1267 HInstanceOf* instance_of = HInstanceOf::cast(v); 1266 HInstanceOf* instance_of = HInstanceOf::cast(v);
1268 LInstruction* result = 1267 LInstruction* result =
1269 new LInstanceOfAndBranch(Use(instance_of->left()), 1268 new LInstanceOfAndBranch(UseFixed(instance_of->left(), eax),
1270 Use(instance_of->right()), 1269 UseFixed(instance_of->right(), edx),
1271 first_id, 1270 first_id,
1272 second_id); 1271 second_id);
1273 return MarkAsCall(result, instr); 1272 return MarkAsCall(result, instr);
1274 } else if (v->IsTypeofIs()) { 1273 } else if (v->IsTypeofIs()) {
1275 HTypeofIs* typeof_is = HTypeofIs::cast(v); 1274 HTypeofIs* typeof_is = HTypeofIs::cast(v);
1276 return new LTypeofIsAndBranch(UseTempRegister(typeof_is->value()), 1275 return new LTypeofIsAndBranch(UseTempRegister(typeof_is->value()),
1277 first_id, 1276 first_id,
1278 second_id); 1277 second_id);
1279 } else { 1278 } else {
1280 if (v->IsConstant()) { 1279 if (v->IsConstant()) {
(...skipping 29 matching lines...) Expand all
1310 } 1309 }
1311 1310
1312 1311
1313 LInstruction* LChunkBuilder::DoArgumentsElements(HArgumentsElements* elems) { 1312 LInstruction* LChunkBuilder::DoArgumentsElements(HArgumentsElements* elems) {
1314 return DefineAsRegister(new LArgumentsElements); 1313 return DefineAsRegister(new LArgumentsElements);
1315 } 1314 }
1316 1315
1317 1316
1318 LInstruction* LChunkBuilder::DoInstanceOf(HInstanceOf* instr) { 1317 LInstruction* LChunkBuilder::DoInstanceOf(HInstanceOf* instr) {
1319 LInstruction* result = 1318 LInstruction* result =
1320 new LInstanceOf(Use(instr->left()), Use(instr->right())); 1319 new LInstanceOf(UseFixed(instr->left(), eax),
1320 UseFixed(instr->right(), edx));
1321 return MarkAsCall(DefineFixed(result, eax), instr); 1321 return MarkAsCall(DefineFixed(result, eax), instr);
1322 } 1322 }
1323 1323
1324 1324
1325 LInstruction* LChunkBuilder::DoApplyArguments(HApplyArguments* instr) { 1325 LInstruction* LChunkBuilder::DoApplyArguments(HApplyArguments* instr) {
1326 LOperand* function = UseFixed(instr->function(), edi); 1326 LOperand* function = UseFixed(instr->function(), edi);
1327 LOperand* receiver = UseFixed(instr->receiver(), eax); 1327 LOperand* receiver = UseFixed(instr->receiver(), eax);
1328 LOperand* length = UseRegisterAtStart(instr->length()); 1328 LOperand* length = UseRegisterAtStart(instr->length());
1329 LOperand* elements = UseRegisterAtStart(instr->elements()); 1329 LOperand* elements = UseRegisterAtStart(instr->elements());
1330 LInstruction* result = new LApplyArguments(function, 1330 LInstruction* result = new LApplyArguments(function,
1331 receiver, 1331 receiver,
1332 length, 1332 length,
1333 elements); 1333 elements);
1334 return MarkAsCall(DefineFixed(result, eax), instr, CAN_DEOPTIMIZE_EAGERLY); 1334 return MarkAsCall(DefineFixed(result, eax), instr, CAN_DEOPTIMIZE_EAGERLY);
1335 } 1335 }
1336 1336
1337 1337
1338 LInstruction* LChunkBuilder::DoPushArgument(HPushArgument* instr) { 1338 LInstruction* LChunkBuilder::DoPushArgument(HPushArgument* instr) {
1339 ++argument_count_; 1339 ++argument_count_;
1340 LOperand* argument = Use(instr->argument()); 1340 LOperand* argument = UseOrConstant(instr->argument());
1341 return new LPushArgument(argument); 1341 return new LPushArgument(argument);
1342 } 1342 }
1343 1343
1344 1344
1345 LInstruction* LChunkBuilder::DoGlobalObject(HGlobalObject* instr) { 1345 LInstruction* LChunkBuilder::DoGlobalObject(HGlobalObject* instr) {
1346 return DefineAsRegister(new LGlobalObject); 1346 return DefineAsRegister(new LGlobalObject);
1347 } 1347 }
1348 1348
1349 1349
1350 LInstruction* LChunkBuilder::DoGlobalReceiver(HGlobalReceiver* instr) { 1350 LInstruction* LChunkBuilder::DoGlobalReceiver(HGlobalReceiver* instr) {
1351 return DefineAsRegister(new LGlobalReceiver); 1351 return DefineAsRegister(new LGlobalReceiver);
1352 } 1352 }
1353 1353
1354 1354
1355 LInstruction* LChunkBuilder::DoCallConstantFunction( 1355 LInstruction* LChunkBuilder::DoCallConstantFunction(
1356 HCallConstantFunction* instr) { 1356 HCallConstantFunction* instr) {
1357 argument_count_ -= instr->argument_count(); 1357 argument_count_ -= instr->argument_count();
1358 return MarkAsCall(DefineFixed(new LCallConstantFunction, eax), instr); 1358 return MarkAsCall(DefineFixed(new LCallConstantFunction, eax), instr);
1359 } 1359 }
1360 1360
1361 1361
1362 LInstruction* LChunkBuilder::DoUnaryMathOperation(HUnaryMathOperation* instr) { 1362 LInstruction* LChunkBuilder::DoUnaryMathOperation(HUnaryMathOperation* instr) {
1363 MathFunctionId op = instr->op(); 1363 BuiltinFunctionId op = instr->op();
1364 LOperand* input = UseRegisterAtStart(instr->value()); 1364 if (op == kMathLog || op == kMathSin || op == kMathCos) {
1365 LInstruction* result = new LUnaryMathOperation(input); 1365 LOperand* input = UseFixedDouble(instr->value(), xmm1);
1366 switch (op) { 1366 LInstruction* result = new LUnaryMathOperation(input);
1367 case kMathAbs: 1367 return MarkAsCall(DefineFixedDouble(result, xmm1), instr);
1368 return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result))); 1368 } else {
1369 case kMathFloor: 1369 LOperand* input = UseRegisterAtStart(instr->value());
1370 return AssignEnvironment(DefineAsRegister(result)); 1370 LInstruction* result = new LUnaryMathOperation(input);
1371 case kMathRound: 1371 switch (op) {
1372 return AssignEnvironment(DefineAsRegister(result)); 1372 case kMathAbs:
1373 case kMathSqrt: 1373 return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result)));
1374 return DefineSameAsFirst(result); 1374 case kMathFloor:
1375 default: 1375 return AssignEnvironment(DefineAsRegister(result));
1376 UNREACHABLE(); 1376 case kMathRound:
1377 return NULL; 1377 return AssignEnvironment(DefineAsRegister(result));
1378 case kMathSqrt:
1379 return DefineSameAsFirst(result);
1380 case kMathPowHalf:
1381 return AssignEnvironment(DefineSameAsFirst(result));
1382 default:
1383 UNREACHABLE();
1384 return NULL;
1385 }
1378 } 1386 }
1379 } 1387 }
1380 1388
1381 1389
1382 LInstruction* LChunkBuilder::DoCallKeyed(HCallKeyed* instr) { 1390 LInstruction* LChunkBuilder::DoCallKeyed(HCallKeyed* instr) {
1383 ASSERT(instr->key()->representation().IsTagged()); 1391 ASSERT(instr->key()->representation().IsTagged());
1384 argument_count_ -= instr->argument_count(); 1392 argument_count_ -= instr->argument_count();
1385 UseFixed(instr->key(), ecx); 1393 UseFixed(instr->key(), ecx);
1386 return MarkAsCall(DefineFixed(new LCallKeyed, eax), instr); 1394 return MarkAsCall(DefineFixed(new LCallKeyed, eax), instr);
1387 } 1395 }
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
1565 return result; 1573 return result;
1566 } else if (instr->representation().IsDouble()) { 1574 } else if (instr->representation().IsDouble()) {
1567 return DoArithmeticD(Token::ADD, instr); 1575 return DoArithmeticD(Token::ADD, instr);
1568 } else { 1576 } else {
1569 ASSERT(instr->representation().IsTagged()); 1577 ASSERT(instr->representation().IsTagged());
1570 return DoArithmeticT(Token::ADD, instr); 1578 return DoArithmeticT(Token::ADD, instr);
1571 } 1579 }
1572 } 1580 }
1573 1581
1574 1582
1583 LInstruction* LChunkBuilder::DoPower(HPower* instr) {
1584 ASSERT(instr->representation().IsDouble());
1585 // We call a C function for double power. It can't trigger a GC.
1586 // We need to use fixed result register for the call.
1587 Representation exponent_type = instr->right()->representation();
1588 ASSERT(instr->left()->representation().IsDouble());
1589 LOperand* left = UseFixedDouble(instr->left(), xmm1);
1590 LOperand* right = exponent_type.IsDouble() ?
1591 UseFixedDouble(instr->right(), xmm2) :
1592 UseFixed(instr->right(), eax);
1593 LPower* result = new LPower(left, right);
1594 return MarkAsCall(DefineFixedDouble(result, xmm3), instr,
1595 CAN_DEOPTIMIZE_EAGERLY);
1596 }
1597
1598
1575 LInstruction* LChunkBuilder::DoCompare(HCompare* instr) { 1599 LInstruction* LChunkBuilder::DoCompare(HCompare* instr) {
1576 Token::Value op = instr->token(); 1600 Token::Value op = instr->token();
1577 if (instr->left()->representation().IsInteger32()) { 1601 if (instr->left()->representation().IsInteger32()) {
1578 ASSERT(instr->right()->representation().IsInteger32()); 1602 ASSERT(instr->right()->representation().IsInteger32());
1579 LOperand* left = UseRegisterAtStart(instr->left()); 1603 LOperand* left = UseRegisterAtStart(instr->left());
1580 LOperand* right = UseOrConstantAtStart(instr->right()); 1604 LOperand* right = UseOrConstantAtStart(instr->right());
1581 return DefineAsRegister(new LCmpID(op, left, right, false)); 1605 return DefineAsRegister(new LCmpID(op, left, right, false));
1582 } else if (instr->left()->representation().IsDouble()) { 1606 } else if (instr->left()->representation().IsDouble()) {
1583 ASSERT(instr->right()->representation().IsDouble()); 1607 ASSERT(instr->right()->representation().IsDouble());
1584 LOperand* left = UseRegisterAtStart(instr->left()); 1608 LOperand* left = UseRegisterAtStart(instr->left());
(...skipping 20 matching lines...) Expand all
1605 1629
1606 LInstruction* LChunkBuilder::DoIsNull(HIsNull* instr) { 1630 LInstruction* LChunkBuilder::DoIsNull(HIsNull* instr) {
1607 ASSERT(instr->value()->representation().IsTagged()); 1631 ASSERT(instr->value()->representation().IsTagged());
1608 LOperand* value = UseRegisterAtStart(instr->value()); 1632 LOperand* value = UseRegisterAtStart(instr->value());
1609 1633
1610 return DefineAsRegister(new LIsNull(value, 1634 return DefineAsRegister(new LIsNull(value,
1611 instr->is_strict())); 1635 instr->is_strict()));
1612 } 1636 }
1613 1637
1614 1638
1639 LInstruction* LChunkBuilder::DoIsObject(HIsObject* instr) {
1640 ASSERT(instr->value()->representation().IsTagged());
1641 LOperand* value = UseRegister(instr->value());
1642
1643 return DefineAsRegister(new LIsObject(value, TempRegister()));
1644 }
1645
1646
1615 LInstruction* LChunkBuilder::DoIsSmi(HIsSmi* instr) { 1647 LInstruction* LChunkBuilder::DoIsSmi(HIsSmi* instr) {
1616 ASSERT(instr->value()->representation().IsTagged()); 1648 ASSERT(instr->value()->representation().IsTagged());
1617 LOperand* value = UseAtStart(instr->value()); 1649 LOperand* value = UseAtStart(instr->value());
1618 1650
1619 return DefineAsRegister(new LIsSmi(value)); 1651 return DefineAsRegister(new LIsSmi(value));
1620 } 1652 }
1621 1653
1622 1654
1623 LInstruction* LChunkBuilder::DoHasInstanceType(HHasInstanceType* instr) { 1655 LInstruction* LChunkBuilder::DoHasInstanceType(HHasInstanceType* instr) {
1624 ASSERT(instr->value()->representation().IsTagged()); 1656 ASSERT(instr->value()->representation().IsTagged());
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
2088 void LPointerMap::PrintTo(StringStream* stream) const { 2120 void LPointerMap::PrintTo(StringStream* stream) const {
2089 stream->Add("{"); 2121 stream->Add("{");
2090 for (int i = 0; i < pointer_operands_.length(); ++i) { 2122 for (int i = 0; i < pointer_operands_.length(); ++i) {
2091 if (i != 0) stream->Add(";"); 2123 if (i != 0) stream->Add(";");
2092 pointer_operands_[i]->PrintTo(stream); 2124 pointer_operands_[i]->PrintTo(stream);
2093 } 2125 }
2094 stream->Add("} @%d", position()); 2126 stream->Add("} @%d", position());
2095 } 2127 }
2096 2128
2097 } } // namespace v8::internal 2129 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ia32/lithium-ia32.h ('k') | src/ia32/macro-assembler-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698