OLD | NEW |
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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 int fp_to_sp_delta, | 306 int fp_to_sp_delta, |
307 Code* optimized_code) | 307 Code* optimized_code) |
308 : isolate_(isolate), | 308 : isolate_(isolate), |
309 function_(function), | 309 function_(function), |
310 bailout_id_(bailout_id), | 310 bailout_id_(bailout_id), |
311 bailout_type_(type), | 311 bailout_type_(type), |
312 from_(from), | 312 from_(from), |
313 fp_to_sp_delta_(fp_to_sp_delta), | 313 fp_to_sp_delta_(fp_to_sp_delta), |
314 input_(NULL), | 314 input_(NULL), |
315 output_count_(0), | 315 output_count_(0), |
| 316 jsframes_count_(0), |
316 output_(NULL), | 317 output_(NULL), |
317 frame_alignment_marker_(isolate->heap()->frame_alignment_marker()), | 318 frame_alignment_marker_(isolate->heap()->frame_alignment_marker()), |
318 has_alignment_padding_(0), | 319 has_alignment_padding_(0), |
319 deferred_heap_numbers_(0) { | 320 deferred_heap_numbers_(0) { |
320 if (FLAG_trace_deopt && type != OSR) { | 321 if (FLAG_trace_deopt && type != OSR) { |
321 if (type == DEBUGGER) { | 322 if (type == DEBUGGER) { |
322 PrintF("**** DEOPT FOR DEBUGGER: "); | 323 PrintF("**** DEOPT FOR DEBUGGER: "); |
323 } else { | 324 } else { |
324 PrintF("**** DEOPT: "); | 325 PrintF("**** DEOPT: "); |
325 } | 326 } |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 int count = iterator.Next(); | 518 int count = iterator.Next(); |
518 ASSERT(output_ == NULL); | 519 ASSERT(output_ == NULL); |
519 output_ = new FrameDescription*[count]; | 520 output_ = new FrameDescription*[count]; |
520 for (int i = 0; i < count; ++i) { | 521 for (int i = 0; i < count; ++i) { |
521 output_[i] = NULL; | 522 output_[i] = NULL; |
522 } | 523 } |
523 output_count_ = count; | 524 output_count_ = count; |
524 | 525 |
525 // Translate each output frame. | 526 // Translate each output frame. |
526 for (int i = 0; i < count; ++i) { | 527 for (int i = 0; i < count; ++i) { |
527 DoComputeFrame(&iterator, i); | 528 // Read the ast node id, function, and frame height for this output frame. |
| 529 Translation::Opcode opcode = |
| 530 static_cast<Translation::Opcode>(iterator.Next()); |
| 531 switch (opcode) { |
| 532 case Translation::FRAME: |
| 533 DoComputeFrame(&iterator, i); |
| 534 jsframes_count_++; |
| 535 break; |
| 536 case Translation::ARGUMENTS_ADAPTOR_FRAME: |
| 537 DoComputeArgumentsAdaptorFrame(&iterator, i); |
| 538 break; |
| 539 default: |
| 540 UNREACHABLE(); |
| 541 break; |
| 542 } |
528 } | 543 } |
529 | 544 |
530 // Print some helpful diagnostic information. | 545 // Print some helpful diagnostic information. |
531 if (FLAG_trace_deopt) { | 546 if (FLAG_trace_deopt) { |
532 double ms = static_cast<double>(OS::Ticks() - start) / 1000; | 547 double ms = static_cast<double>(OS::Ticks() - start) / 1000; |
533 int index = output_count_ - 1; // Index of the topmost frame. | 548 int index = output_count_ - 1; // Index of the topmost frame. |
534 JSFunction* function = output_[index]->GetFunction(); | 549 JSFunction* function = output_[index]->GetFunction(); |
535 PrintF("[deoptimizing: end 0x%08" V8PRIxPTR " ", | 550 PrintF("[deoptimizing: end 0x%08" V8PRIxPTR " ", |
536 reinterpret_cast<intptr_t>(function)); | 551 reinterpret_cast<intptr_t>(function)); |
537 function->PrintName(); | 552 function->PrintName(); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 static_cast<Translation::Opcode>(iterator->Next()); | 631 static_cast<Translation::Opcode>(iterator->Next()); |
617 while (opcode == Translation::DUPLICATE) { | 632 while (opcode == Translation::DUPLICATE) { |
618 opcode = static_cast<Translation::Opcode>(iterator->Next()); | 633 opcode = static_cast<Translation::Opcode>(iterator->Next()); |
619 iterator->Skip(Translation::NumberOfOperandsFor(opcode)); | 634 iterator->Skip(Translation::NumberOfOperandsFor(opcode)); |
620 opcode = static_cast<Translation::Opcode>(iterator->Next()); | 635 opcode = static_cast<Translation::Opcode>(iterator->Next()); |
621 } | 636 } |
622 | 637 |
623 switch (opcode) { | 638 switch (opcode) { |
624 case Translation::BEGIN: | 639 case Translation::BEGIN: |
625 case Translation::FRAME: | 640 case Translation::FRAME: |
| 641 case Translation::ARGUMENTS_ADAPTOR_FRAME: |
626 case Translation::DUPLICATE: | 642 case Translation::DUPLICATE: |
627 UNREACHABLE(); | 643 UNREACHABLE(); |
628 return; | 644 return; |
629 | 645 |
630 case Translation::REGISTER: { | 646 case Translation::REGISTER: { |
631 int input_reg = iterator->Next(); | 647 int input_reg = iterator->Next(); |
632 intptr_t input_value = input_->GetRegister(input_reg); | 648 intptr_t input_value = input_->GetRegister(input_reg); |
633 if (FLAG_trace_deopt) { | 649 if (FLAG_trace_deopt) { |
634 PrintF( | 650 PrintF( |
635 " 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08" V8PRIxPTR " ; %s ", | 651 " 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08" V8PRIxPTR " ; %s ", |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 Translation::Opcode opcode = | 818 Translation::Opcode opcode = |
803 static_cast<Translation::Opcode>(iterator->Next()); | 819 static_cast<Translation::Opcode>(iterator->Next()); |
804 bool duplicate = (opcode == Translation::DUPLICATE); | 820 bool duplicate = (opcode == Translation::DUPLICATE); |
805 if (duplicate) { | 821 if (duplicate) { |
806 opcode = static_cast<Translation::Opcode>(iterator->Next()); | 822 opcode = static_cast<Translation::Opcode>(iterator->Next()); |
807 } | 823 } |
808 | 824 |
809 switch (opcode) { | 825 switch (opcode) { |
810 case Translation::BEGIN: | 826 case Translation::BEGIN: |
811 case Translation::FRAME: | 827 case Translation::FRAME: |
| 828 case Translation::ARGUMENTS_ADAPTOR_FRAME: |
812 case Translation::DUPLICATE: | 829 case Translation::DUPLICATE: |
813 UNREACHABLE(); // Malformed input. | 830 UNREACHABLE(); // Malformed input. |
814 return false; | 831 return false; |
815 | 832 |
816 case Translation::REGISTER: { | 833 case Translation::REGISTER: { |
817 int output_reg = iterator->Next(); | 834 int output_reg = iterator->Next(); |
818 if (FLAG_trace_osr) { | 835 if (FLAG_trace_osr) { |
819 PrintF(" %s <- 0x%08" V8PRIxPTR " ; [sp + %d]\n", | 836 PrintF(" %s <- 0x%08" V8PRIxPTR " ; [sp + %d]\n", |
820 converter.NameOfCPURegister(output_reg), | 837 converter.NameOfCPURegister(output_reg), |
821 input_value, | 838 input_value, |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1235 | 1252 |
1236 Handle<ByteArray> TranslationBuffer::CreateByteArray() { | 1253 Handle<ByteArray> TranslationBuffer::CreateByteArray() { |
1237 int length = contents_.length(); | 1254 int length = contents_.length(); |
1238 Handle<ByteArray> result = | 1255 Handle<ByteArray> result = |
1239 Isolate::Current()->factory()->NewByteArray(length, TENURED); | 1256 Isolate::Current()->factory()->NewByteArray(length, TENURED); |
1240 memcpy(result->GetDataStartAddress(), contents_.ToVector().start(), length); | 1257 memcpy(result->GetDataStartAddress(), contents_.ToVector().start(), length); |
1241 return result; | 1258 return result; |
1242 } | 1259 } |
1243 | 1260 |
1244 | 1261 |
| 1262 void Translation::BeginArgumentsAdaptorFrame(int literal_id, unsigned height) { |
| 1263 buffer_->Add(ARGUMENTS_ADAPTOR_FRAME); |
| 1264 buffer_->Add(literal_id); |
| 1265 buffer_->Add(height); |
| 1266 } |
| 1267 |
| 1268 |
1245 void Translation::BeginFrame(int node_id, int literal_id, unsigned height) { | 1269 void Translation::BeginFrame(int node_id, int literal_id, unsigned height) { |
1246 buffer_->Add(FRAME); | 1270 buffer_->Add(FRAME); |
1247 buffer_->Add(node_id); | 1271 buffer_->Add(node_id); |
1248 buffer_->Add(literal_id); | 1272 buffer_->Add(literal_id); |
1249 buffer_->Add(height); | 1273 buffer_->Add(height); |
1250 } | 1274 } |
1251 | 1275 |
1252 | 1276 |
1253 void Translation::StoreRegister(Register reg) { | 1277 void Translation::StoreRegister(Register reg) { |
1254 buffer_->Add(REGISTER); | 1278 buffer_->Add(REGISTER); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1309 return 0; | 1333 return 0; |
1310 case BEGIN: | 1334 case BEGIN: |
1311 case REGISTER: | 1335 case REGISTER: |
1312 case INT32_REGISTER: | 1336 case INT32_REGISTER: |
1313 case DOUBLE_REGISTER: | 1337 case DOUBLE_REGISTER: |
1314 case STACK_SLOT: | 1338 case STACK_SLOT: |
1315 case INT32_STACK_SLOT: | 1339 case INT32_STACK_SLOT: |
1316 case DOUBLE_STACK_SLOT: | 1340 case DOUBLE_STACK_SLOT: |
1317 case LITERAL: | 1341 case LITERAL: |
1318 return 1; | 1342 return 1; |
| 1343 case ARGUMENTS_ADAPTOR_FRAME: |
| 1344 return 2; |
1319 case FRAME: | 1345 case FRAME: |
1320 return 3; | 1346 return 3; |
1321 } | 1347 } |
1322 UNREACHABLE(); | 1348 UNREACHABLE(); |
1323 return -1; | 1349 return -1; |
1324 } | 1350 } |
1325 | 1351 |
1326 | 1352 |
1327 #if defined(OBJECT_PRINT) || defined(ENABLE_DISASSEMBLER) | 1353 #if defined(OBJECT_PRINT) || defined(ENABLE_DISASSEMBLER) |
1328 | 1354 |
1329 const char* Translation::StringFor(Opcode opcode) { | 1355 const char* Translation::StringFor(Opcode opcode) { |
1330 switch (opcode) { | 1356 switch (opcode) { |
1331 case BEGIN: | 1357 case BEGIN: |
1332 return "BEGIN"; | 1358 return "BEGIN"; |
1333 case FRAME: | 1359 case FRAME: |
1334 return "FRAME"; | 1360 return "FRAME"; |
| 1361 case ARGUMENTS_ADAPTOR_FRAME: |
| 1362 return "ARGUMENTS_ADAPTOR_FRAME"; |
1335 case REGISTER: | 1363 case REGISTER: |
1336 return "REGISTER"; | 1364 return "REGISTER"; |
1337 case INT32_REGISTER: | 1365 case INT32_REGISTER: |
1338 return "INT32_REGISTER"; | 1366 return "INT32_REGISTER"; |
1339 case DOUBLE_REGISTER: | 1367 case DOUBLE_REGISTER: |
1340 return "DOUBLE_REGISTER"; | 1368 return "DOUBLE_REGISTER"; |
1341 case STACK_SLOT: | 1369 case STACK_SLOT: |
1342 return "STACK_SLOT"; | 1370 return "STACK_SLOT"; |
1343 case INT32_STACK_SLOT: | 1371 case INT32_STACK_SLOT: |
1344 return "INT32_STACK_SLOT"; | 1372 return "INT32_STACK_SLOT"; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1379 // Thus we build a temporary structure in malloced space. | 1407 // Thus we build a temporary structure in malloced space. |
1380 SlotRef SlotRef::ComputeSlotForNextArgument(TranslationIterator* iterator, | 1408 SlotRef SlotRef::ComputeSlotForNextArgument(TranslationIterator* iterator, |
1381 DeoptimizationInputData* data, | 1409 DeoptimizationInputData* data, |
1382 JavaScriptFrame* frame) { | 1410 JavaScriptFrame* frame) { |
1383 Translation::Opcode opcode = | 1411 Translation::Opcode opcode = |
1384 static_cast<Translation::Opcode>(iterator->Next()); | 1412 static_cast<Translation::Opcode>(iterator->Next()); |
1385 | 1413 |
1386 switch (opcode) { | 1414 switch (opcode) { |
1387 case Translation::BEGIN: | 1415 case Translation::BEGIN: |
1388 case Translation::FRAME: | 1416 case Translation::FRAME: |
| 1417 case Translation::ARGUMENTS_ADAPTOR_FRAME: |
1389 // Peeled off before getting here. | 1418 // Peeled off before getting here. |
1390 break; | 1419 break; |
1391 | 1420 |
1392 case Translation::ARGUMENTS_OBJECT: | 1421 case Translation::ARGUMENTS_OBJECT: |
1393 // This can be only emitted for local slots not for argument slots. | 1422 // This can be only emitted for local slots not for argument slots. |
1394 break; | 1423 break; |
1395 | 1424 |
1396 case Translation::REGISTER: | 1425 case Translation::REGISTER: |
1397 case Translation::INT32_REGISTER: | 1426 case Translation::INT32_REGISTER: |
1398 case Translation::DOUBLE_REGISTER: | 1427 case Translation::DOUBLE_REGISTER: |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1498 | 1527 |
1499 void DeoptimizedFrameInfo::Iterate(ObjectVisitor* v) { | 1528 void DeoptimizedFrameInfo::Iterate(ObjectVisitor* v) { |
1500 v->VisitPointer(BitCast<Object**>(&function_)); | 1529 v->VisitPointer(BitCast<Object**>(&function_)); |
1501 v->VisitPointers(parameters_, parameters_ + parameters_count_); | 1530 v->VisitPointers(parameters_, parameters_ + parameters_count_); |
1502 v->VisitPointers(expression_stack_, expression_stack_ + expression_count_); | 1531 v->VisitPointers(expression_stack_, expression_stack_ + expression_count_); |
1503 } | 1532 } |
1504 | 1533 |
1505 #endif // ENABLE_DEBUGGER_SUPPORT | 1534 #endif // ENABLE_DEBUGGER_SUPPORT |
1506 | 1535 |
1507 } } // namespace v8::internal | 1536 } } // namespace v8::internal |
OLD | NEW |