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 1425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1436 // Move to next in list. | 1436 // Move to next in list. |
1437 prev = current; | 1437 prev = current; |
1438 current = current->next(); | 1438 current = current->next(); |
1439 } | 1439 } |
1440 // Deoptimizing code is removed through weak callback. Each object is expected | 1440 // Deoptimizing code is removed through weak callback. Each object is expected |
1441 // to be removed once and only once. | 1441 // to be removed once and only once. |
1442 UNREACHABLE(); | 1442 UNREACHABLE(); |
1443 } | 1443 } |
1444 | 1444 |
1445 | 1445 |
1446 static Object* CutOutRelatedFunctionsList(Context* context, | |
1447 Code* code, | |
1448 Object* undefined) { | |
1449 Object* result_list_head = undefined; | |
1450 Object* head; | |
1451 Object* current; | |
1452 current = head = context->get(Context::OPTIMIZED_FUNCTIONS_LIST); | |
1453 JSFunction* prev = NULL; | |
1454 while (!current->IsUndefined()) { | |
danno
2012/10/21 19:56:15
Why not current != undefined, if you already have
ulan
2012/10/22 08:39:56
Done.
| |
1455 JSFunction* func = JSFunction::cast(current); | |
1456 current = func->next_function_link(); | |
1457 if (func->code() == code) { | |
1458 func->set_next_function_link(result_list_head); | |
1459 result_list_head = func; | |
1460 if (prev) { | |
1461 prev->set_next_function_link(current); | |
1462 } else { | |
1463 head = current; | |
1464 } | |
1465 } else { | |
1466 prev = func; | |
1467 } | |
1468 } | |
1469 if (head != context->get(Context::OPTIMIZED_FUNCTIONS_LIST)) { | |
danno
2012/10/21 19:56:15
If this extra compare just to avoid a write barrie
ulan
2012/10/22 08:39:56
Yep, I think head will be unchanged most of the ti
| |
1470 context->set(Context::OPTIMIZED_FUNCTIONS_LIST, head); | |
1471 } | |
1472 return result_list_head; | |
1473 } | |
1474 | |
1475 | |
1476 void Deoptimizer::ReplaceCodeForRelatedFunctions(JSFunction* function, | |
1477 Code* code) { | |
1478 Context* context = function->context()->native_context(); | |
1479 | |
1480 SharedFunctionInfo* shared = function->shared(); | |
1481 | |
1482 Object* undefined = Isolate::Current()->heap()->undefined_value(); | |
1483 Object* current = CutOutRelatedFunctionsList(context, code, undefined); | |
1484 | |
1485 while (!current->IsUndefined()) { | |
danno
2012/10/21 19:56:15
Why not current != undefined, if you already have
ulan
2012/10/22 08:39:56
Done.
| |
1486 JSFunction* func = JSFunction::cast(current); | |
1487 current = func->next_function_link(); | |
1488 func->set_code(shared->code()); | |
1489 func->set_next_function_link(undefined); | |
1490 } | |
1491 } | |
1492 | |
1493 | |
1446 FrameDescription::FrameDescription(uint32_t frame_size, | 1494 FrameDescription::FrameDescription(uint32_t frame_size, |
1447 JSFunction* function) | 1495 JSFunction* function) |
1448 : frame_size_(frame_size), | 1496 : frame_size_(frame_size), |
1449 function_(function), | 1497 function_(function), |
1450 top_(kZapUint32), | 1498 top_(kZapUint32), |
1451 pc_(kZapUint32), | 1499 pc_(kZapUint32), |
1452 fp_(kZapUint32), | 1500 fp_(kZapUint32), |
1453 context_(kZapUint32) { | 1501 context_(kZapUint32) { |
1454 // Zap all the registers. | 1502 // Zap all the registers. |
1455 for (int r = 0; r < Register::kNumRegisters; r++) { | 1503 for (int r = 0; r < Register::kNumRegisters; r++) { |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1941 | 1989 |
1942 void DeoptimizedFrameInfo::Iterate(ObjectVisitor* v) { | 1990 void DeoptimizedFrameInfo::Iterate(ObjectVisitor* v) { |
1943 v->VisitPointer(BitCast<Object**>(&function_)); | 1991 v->VisitPointer(BitCast<Object**>(&function_)); |
1944 v->VisitPointers(parameters_, parameters_ + parameters_count_); | 1992 v->VisitPointers(parameters_, parameters_ + parameters_count_); |
1945 v->VisitPointers(expression_stack_, expression_stack_ + expression_count_); | 1993 v->VisitPointers(expression_stack_, expression_stack_ + expression_count_); |
1946 } | 1994 } |
1947 | 1995 |
1948 #endif // ENABLE_DEBUGGER_SUPPORT | 1996 #endif // ENABLE_DEBUGGER_SUPPORT |
1949 | 1997 |
1950 } } // namespace v8::internal | 1998 } } // namespace v8::internal |
OLD | NEW |