OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 VisitAllOptimizedFunctionsForGlobalObject(object, &visitor); | 265 VisitAllOptimizedFunctionsForGlobalObject(object, &visitor); |
266 } | 266 } |
267 | 267 |
268 | 268 |
269 void Deoptimizer::VisitAllOptimizedFunctionsForContext( | 269 void Deoptimizer::VisitAllOptimizedFunctionsForContext( |
270 Context* context, OptimizedFunctionVisitor* visitor) { | 270 Context* context, OptimizedFunctionVisitor* visitor) { |
271 Isolate* isolate = context->GetIsolate(); | 271 Isolate* isolate = context->GetIsolate(); |
272 ZoneScope zone_scope(isolate->runtime_zone(), DELETE_ON_EXIT); | 272 ZoneScope zone_scope(isolate->runtime_zone(), DELETE_ON_EXIT); |
273 AssertNoAllocation no_allocation; | 273 AssertNoAllocation no_allocation; |
274 | 274 |
275 ASSERT(context->IsNativeContext()); | 275 ASSERT(context->IsGlobalContext()); |
276 | 276 |
277 visitor->EnterContext(context); | 277 visitor->EnterContext(context); |
278 | 278 |
279 // Create a snapshot of the optimized functions list. This is needed because | 279 // Create a snapshot of the optimized functions list. This is needed because |
280 // visitors might remove more than one link from the list at once. | 280 // visitors might remove more than one link from the list at once. |
281 ZoneList<JSFunction*> snapshot(1, isolate->runtime_zone()); | 281 ZoneList<JSFunction*> snapshot(1, isolate->runtime_zone()); |
282 Object* element = context->OptimizedFunctionsListHead(); | 282 Object* element = context->OptimizedFunctionsListHead(); |
283 while (!element->IsUndefined()) { | 283 while (!element->IsUndefined()) { |
284 JSFunction* element_function = JSFunction::cast(element); | 284 JSFunction* element_function = JSFunction::cast(element); |
285 snapshot.Add(element_function, isolate->runtime_zone()); | 285 snapshot.Add(element_function, isolate->runtime_zone()); |
(...skipping 10 matching lines...) Expand all Loading... |
296 | 296 |
297 | 297 |
298 void Deoptimizer::VisitAllOptimizedFunctionsForGlobalObject( | 298 void Deoptimizer::VisitAllOptimizedFunctionsForGlobalObject( |
299 JSObject* object, OptimizedFunctionVisitor* visitor) { | 299 JSObject* object, OptimizedFunctionVisitor* visitor) { |
300 AssertNoAllocation no_allocation; | 300 AssertNoAllocation no_allocation; |
301 | 301 |
302 if (object->IsJSGlobalProxy()) { | 302 if (object->IsJSGlobalProxy()) { |
303 Object* proto = object->GetPrototype(); | 303 Object* proto = object->GetPrototype(); |
304 ASSERT(proto->IsJSGlobalObject()); | 304 ASSERT(proto->IsJSGlobalObject()); |
305 VisitAllOptimizedFunctionsForContext( | 305 VisitAllOptimizedFunctionsForContext( |
306 GlobalObject::cast(proto)->native_context(), visitor); | 306 GlobalObject::cast(proto)->global_context(), visitor); |
307 } else if (object->IsGlobalObject()) { | 307 } else if (object->IsGlobalObject()) { |
308 VisitAllOptimizedFunctionsForContext( | 308 VisitAllOptimizedFunctionsForContext( |
309 GlobalObject::cast(object)->native_context(), visitor); | 309 GlobalObject::cast(object)->global_context(), visitor); |
310 } | 310 } |
311 } | 311 } |
312 | 312 |
313 | 313 |
314 void Deoptimizer::VisitAllOptimizedFunctions( | 314 void Deoptimizer::VisitAllOptimizedFunctions( |
315 OptimizedFunctionVisitor* visitor) { | 315 OptimizedFunctionVisitor* visitor) { |
316 AssertNoAllocation no_allocation; | 316 AssertNoAllocation no_allocation; |
317 | 317 |
318 // Run through the list of all native contexts and deoptimize. | 318 // Run through the list of all global contexts and deoptimize. |
319 Object* context = Isolate::Current()->heap()->native_contexts_list(); | 319 Object* context = Isolate::Current()->heap()->global_contexts_list(); |
320 while (!context->IsUndefined()) { | 320 while (!context->IsUndefined()) { |
321 // GC can happen when the context is not fully initialized, | 321 // GC can happen when the context is not fully initialized, |
322 // so the global field of the context can be undefined. | 322 // so the global field of the context can be undefined. |
323 Object* global = Context::cast(context)->get(Context::GLOBAL_OBJECT_INDEX); | 323 Object* global = Context::cast(context)->get(Context::GLOBAL_INDEX); |
324 if (!global->IsUndefined()) { | 324 if (!global->IsUndefined()) { |
325 VisitAllOptimizedFunctionsForGlobalObject(JSObject::cast(global), | 325 VisitAllOptimizedFunctionsForGlobalObject(JSObject::cast(global), |
326 visitor); | 326 visitor); |
327 } | 327 } |
328 context = Context::cast(context)->get(Context::NEXT_CONTEXT_LINK); | 328 context = Context::cast(context)->get(Context::NEXT_CONTEXT_LINK); |
329 } | 329 } |
330 } | 330 } |
331 | 331 |
332 | 332 |
333 void Deoptimizer::HandleWeakDeoptimizedCode( | 333 void Deoptimizer::HandleWeakDeoptimizedCode( |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 case Translation::JS_FRAME: | 582 case Translation::JS_FRAME: |
583 DoComputeJSFrame(&iterator, i); | 583 DoComputeJSFrame(&iterator, i); |
584 jsframe_count_++; | 584 jsframe_count_++; |
585 break; | 585 break; |
586 case Translation::ARGUMENTS_ADAPTOR_FRAME: | 586 case Translation::ARGUMENTS_ADAPTOR_FRAME: |
587 DoComputeArgumentsAdaptorFrame(&iterator, i); | 587 DoComputeArgumentsAdaptorFrame(&iterator, i); |
588 break; | 588 break; |
589 case Translation::CONSTRUCT_STUB_FRAME: | 589 case Translation::CONSTRUCT_STUB_FRAME: |
590 DoComputeConstructStubFrame(&iterator, i); | 590 DoComputeConstructStubFrame(&iterator, i); |
591 break; | 591 break; |
592 case Translation::SETTER_STUB_FRAME: | 592 default: |
593 DoComputeSetterStubFrame(&iterator, i); | |
594 break; | |
595 case Translation::BEGIN: | |
596 case Translation::REGISTER: | |
597 case Translation::INT32_REGISTER: | |
598 case Translation::DOUBLE_REGISTER: | |
599 case Translation::STACK_SLOT: | |
600 case Translation::INT32_STACK_SLOT: | |
601 case Translation::DOUBLE_STACK_SLOT: | |
602 case Translation::LITERAL: | |
603 case Translation::ARGUMENTS_OBJECT: | |
604 case Translation::DUPLICATE: | |
605 UNREACHABLE(); | 593 UNREACHABLE(); |
606 break; | 594 break; |
607 } | 595 } |
608 } | 596 } |
609 | 597 |
610 // Print some helpful diagnostic information. | 598 // Print some helpful diagnostic information. |
611 if (FLAG_trace_deopt) { | 599 if (FLAG_trace_deopt) { |
612 double ms = static_cast<double>(OS::Ticks() - start) / 1000; | 600 double ms = static_cast<double>(OS::Ticks() - start) / 1000; |
613 int index = output_count_ - 1; // Index of the topmost frame. | 601 int index = output_count_ - 1; // Index of the topmost frame. |
614 JSFunction* function = output_[index]->GetFunction(); | 602 JSFunction* function = output_[index]->GetFunction(); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 opcode = static_cast<Translation::Opcode>(iterator->Next()); | 701 opcode = static_cast<Translation::Opcode>(iterator->Next()); |
714 iterator->Skip(Translation::NumberOfOperandsFor(opcode)); | 702 iterator->Skip(Translation::NumberOfOperandsFor(opcode)); |
715 opcode = static_cast<Translation::Opcode>(iterator->Next()); | 703 opcode = static_cast<Translation::Opcode>(iterator->Next()); |
716 } | 704 } |
717 | 705 |
718 switch (opcode) { | 706 switch (opcode) { |
719 case Translation::BEGIN: | 707 case Translation::BEGIN: |
720 case Translation::JS_FRAME: | 708 case Translation::JS_FRAME: |
721 case Translation::ARGUMENTS_ADAPTOR_FRAME: | 709 case Translation::ARGUMENTS_ADAPTOR_FRAME: |
722 case Translation::CONSTRUCT_STUB_FRAME: | 710 case Translation::CONSTRUCT_STUB_FRAME: |
723 case Translation::SETTER_STUB_FRAME: | |
724 case Translation::DUPLICATE: | 711 case Translation::DUPLICATE: |
725 UNREACHABLE(); | 712 UNREACHABLE(); |
726 return; | 713 return; |
727 | 714 |
728 case Translation::REGISTER: { | 715 case Translation::REGISTER: { |
729 int input_reg = iterator->Next(); | 716 int input_reg = iterator->Next(); |
730 intptr_t input_value = input_->GetRegister(input_reg); | 717 intptr_t input_value = input_->GetRegister(input_reg); |
731 if (FLAG_trace_deopt) { | 718 if (FLAG_trace_deopt) { |
732 PrintF( | 719 PrintF( |
733 " 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08" V8PRIxPTR " ; %s ", | 720 " 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08" V8PRIxPTR " ; %s ", |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
901 bool duplicate = (opcode == Translation::DUPLICATE); | 888 bool duplicate = (opcode == Translation::DUPLICATE); |
902 if (duplicate) { | 889 if (duplicate) { |
903 opcode = static_cast<Translation::Opcode>(iterator->Next()); | 890 opcode = static_cast<Translation::Opcode>(iterator->Next()); |
904 } | 891 } |
905 | 892 |
906 switch (opcode) { | 893 switch (opcode) { |
907 case Translation::BEGIN: | 894 case Translation::BEGIN: |
908 case Translation::JS_FRAME: | 895 case Translation::JS_FRAME: |
909 case Translation::ARGUMENTS_ADAPTOR_FRAME: | 896 case Translation::ARGUMENTS_ADAPTOR_FRAME: |
910 case Translation::CONSTRUCT_STUB_FRAME: | 897 case Translation::CONSTRUCT_STUB_FRAME: |
911 case Translation::SETTER_STUB_FRAME: | |
912 case Translation::DUPLICATE: | 898 case Translation::DUPLICATE: |
913 UNREACHABLE(); // Malformed input. | 899 UNREACHABLE(); // Malformed input. |
914 return false; | 900 return false; |
915 | 901 |
916 case Translation::REGISTER: { | 902 case Translation::REGISTER: { |
917 int output_reg = iterator->Next(); | 903 int output_reg = iterator->Next(); |
918 if (FLAG_trace_osr) { | 904 if (FLAG_trace_osr) { |
919 PrintF(" %s <- 0x%08" V8PRIxPTR " ; [sp + %d]\n", | 905 PrintF(" %s <- 0x%08" V8PRIxPTR " ; [sp + %d]\n", |
920 converter.NameOfCPURegister(output_reg), | 906 converter.NameOfCPURegister(output_reg), |
921 input_value, | 907 input_value, |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1357 } | 1343 } |
1358 | 1344 |
1359 | 1345 |
1360 void Translation::BeginConstructStubFrame(int literal_id, unsigned height) { | 1346 void Translation::BeginConstructStubFrame(int literal_id, unsigned height) { |
1361 buffer_->Add(CONSTRUCT_STUB_FRAME, zone()); | 1347 buffer_->Add(CONSTRUCT_STUB_FRAME, zone()); |
1362 buffer_->Add(literal_id, zone()); | 1348 buffer_->Add(literal_id, zone()); |
1363 buffer_->Add(height, zone()); | 1349 buffer_->Add(height, zone()); |
1364 } | 1350 } |
1365 | 1351 |
1366 | 1352 |
1367 void Translation::BeginSetterStubFrame(int literal_id) { | |
1368 buffer_->Add(SETTER_STUB_FRAME, zone()); | |
1369 buffer_->Add(literal_id, zone()); | |
1370 } | |
1371 | |
1372 | |
1373 void Translation::BeginArgumentsAdaptorFrame(int literal_id, unsigned height) { | 1353 void Translation::BeginArgumentsAdaptorFrame(int literal_id, unsigned height) { |
1374 buffer_->Add(ARGUMENTS_ADAPTOR_FRAME, zone()); | 1354 buffer_->Add(ARGUMENTS_ADAPTOR_FRAME, zone()); |
1375 buffer_->Add(literal_id, zone()); | 1355 buffer_->Add(literal_id, zone()); |
1376 buffer_->Add(height, zone()); | 1356 buffer_->Add(height, zone()); |
1377 } | 1357 } |
1378 | 1358 |
1379 | 1359 |
1380 void Translation::BeginJSFrame(BailoutId node_id, | 1360 void Translation::BeginJSFrame(BailoutId node_id, |
1381 int literal_id, | 1361 int literal_id, |
1382 unsigned height) { | 1362 unsigned height) { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1437 void Translation::MarkDuplicate() { | 1417 void Translation::MarkDuplicate() { |
1438 buffer_->Add(DUPLICATE, zone()); | 1418 buffer_->Add(DUPLICATE, zone()); |
1439 } | 1419 } |
1440 | 1420 |
1441 | 1421 |
1442 int Translation::NumberOfOperandsFor(Opcode opcode) { | 1422 int Translation::NumberOfOperandsFor(Opcode opcode) { |
1443 switch (opcode) { | 1423 switch (opcode) { |
1444 case ARGUMENTS_OBJECT: | 1424 case ARGUMENTS_OBJECT: |
1445 case DUPLICATE: | 1425 case DUPLICATE: |
1446 return 0; | 1426 return 0; |
1447 case SETTER_STUB_FRAME: | |
1448 case REGISTER: | 1427 case REGISTER: |
1449 case INT32_REGISTER: | 1428 case INT32_REGISTER: |
1450 case DOUBLE_REGISTER: | 1429 case DOUBLE_REGISTER: |
1451 case STACK_SLOT: | 1430 case STACK_SLOT: |
1452 case INT32_STACK_SLOT: | 1431 case INT32_STACK_SLOT: |
1453 case DOUBLE_STACK_SLOT: | 1432 case DOUBLE_STACK_SLOT: |
1454 case LITERAL: | 1433 case LITERAL: |
1455 return 1; | 1434 return 1; |
1456 case BEGIN: | 1435 case BEGIN: |
1457 case ARGUMENTS_ADAPTOR_FRAME: | 1436 case ARGUMENTS_ADAPTOR_FRAME: |
(...skipping 12 matching lines...) Expand all Loading... |
1470 const char* Translation::StringFor(Opcode opcode) { | 1449 const char* Translation::StringFor(Opcode opcode) { |
1471 switch (opcode) { | 1450 switch (opcode) { |
1472 case BEGIN: | 1451 case BEGIN: |
1473 return "BEGIN"; | 1452 return "BEGIN"; |
1474 case JS_FRAME: | 1453 case JS_FRAME: |
1475 return "JS_FRAME"; | 1454 return "JS_FRAME"; |
1476 case ARGUMENTS_ADAPTOR_FRAME: | 1455 case ARGUMENTS_ADAPTOR_FRAME: |
1477 return "ARGUMENTS_ADAPTOR_FRAME"; | 1456 return "ARGUMENTS_ADAPTOR_FRAME"; |
1478 case CONSTRUCT_STUB_FRAME: | 1457 case CONSTRUCT_STUB_FRAME: |
1479 return "CONSTRUCT_STUB_FRAME"; | 1458 return "CONSTRUCT_STUB_FRAME"; |
1480 case SETTER_STUB_FRAME: | |
1481 return "SETTER_STUB_FRAME"; | |
1482 case REGISTER: | 1459 case REGISTER: |
1483 return "REGISTER"; | 1460 return "REGISTER"; |
1484 case INT32_REGISTER: | 1461 case INT32_REGISTER: |
1485 return "INT32_REGISTER"; | 1462 return "INT32_REGISTER"; |
1486 case DOUBLE_REGISTER: | 1463 case DOUBLE_REGISTER: |
1487 return "DOUBLE_REGISTER"; | 1464 return "DOUBLE_REGISTER"; |
1488 case STACK_SLOT: | 1465 case STACK_SLOT: |
1489 return "STACK_SLOT"; | 1466 return "STACK_SLOT"; |
1490 case INT32_STACK_SLOT: | 1467 case INT32_STACK_SLOT: |
1491 return "INT32_STACK_SLOT"; | 1468 return "INT32_STACK_SLOT"; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1528 DeoptimizationInputData* data, | 1505 DeoptimizationInputData* data, |
1529 JavaScriptFrame* frame) { | 1506 JavaScriptFrame* frame) { |
1530 Translation::Opcode opcode = | 1507 Translation::Opcode opcode = |
1531 static_cast<Translation::Opcode>(iterator->Next()); | 1508 static_cast<Translation::Opcode>(iterator->Next()); |
1532 | 1509 |
1533 switch (opcode) { | 1510 switch (opcode) { |
1534 case Translation::BEGIN: | 1511 case Translation::BEGIN: |
1535 case Translation::JS_FRAME: | 1512 case Translation::JS_FRAME: |
1536 case Translation::ARGUMENTS_ADAPTOR_FRAME: | 1513 case Translation::ARGUMENTS_ADAPTOR_FRAME: |
1537 case Translation::CONSTRUCT_STUB_FRAME: | 1514 case Translation::CONSTRUCT_STUB_FRAME: |
1538 case Translation::SETTER_STUB_FRAME: | |
1539 // Peeled off before getting here. | 1515 // Peeled off before getting here. |
1540 break; | 1516 break; |
1541 | 1517 |
1542 case Translation::ARGUMENTS_OBJECT: | 1518 case Translation::ARGUMENTS_OBJECT: |
1543 // This can be only emitted for local slots not for argument slots. | 1519 // This can be only emitted for local slots not for argument slots. |
1544 break; | 1520 break; |
1545 | 1521 |
1546 case Translation::REGISTER: | 1522 case Translation::REGISTER: |
1547 case Translation::INT32_REGISTER: | 1523 case Translation::INT32_REGISTER: |
1548 case Translation::DOUBLE_REGISTER: | 1524 case Translation::DOUBLE_REGISTER: |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1697 | 1673 |
1698 void DeoptimizedFrameInfo::Iterate(ObjectVisitor* v) { | 1674 void DeoptimizedFrameInfo::Iterate(ObjectVisitor* v) { |
1699 v->VisitPointer(BitCast<Object**>(&function_)); | 1675 v->VisitPointer(BitCast<Object**>(&function_)); |
1700 v->VisitPointers(parameters_, parameters_ + parameters_count_); | 1676 v->VisitPointers(parameters_, parameters_ + parameters_count_); |
1701 v->VisitPointers(expression_stack_, expression_stack_ + expression_count_); | 1677 v->VisitPointers(expression_stack_, expression_stack_ + expression_count_); |
1702 } | 1678 } |
1703 | 1679 |
1704 #endif // ENABLE_DEBUGGER_SUPPORT | 1680 #endif // ENABLE_DEBUGGER_SUPPORT |
1705 | 1681 |
1706 } } // namespace v8::internal | 1682 } } // namespace v8::internal |
OLD | NEW |