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 1215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1226 | 1226 |
1227 // Returns true if an instance of candidate were inlined into function's code. | 1227 // Returns true if an instance of candidate were inlined into function's code. |
1228 static bool IsInlined(JSFunction* function, SharedFunctionInfo* candidate) { | 1228 static bool IsInlined(JSFunction* function, SharedFunctionInfo* candidate) { |
1229 DisallowHeapAllocation no_gc; | 1229 DisallowHeapAllocation no_gc; |
1230 | 1230 |
1231 if (function->code()->kind() != Code::OPTIMIZED_FUNCTION) return false; | 1231 if (function->code()->kind() != Code::OPTIMIZED_FUNCTION) return false; |
1232 | 1232 |
1233 DeoptimizationInputData* data = | 1233 DeoptimizationInputData* data = |
1234 DeoptimizationInputData::cast(function->code()->deoptimization_data()); | 1234 DeoptimizationInputData::cast(function->code()->deoptimization_data()); |
1235 | 1235 |
1236 if (data == HEAP->empty_fixed_array()) return false; | 1236 if (data == function->GetIsolate()->heap()->empty_fixed_array()) { |
| 1237 return false; |
| 1238 } |
1237 | 1239 |
1238 FixedArray* literals = data->LiteralArray(); | 1240 FixedArray* literals = data->LiteralArray(); |
1239 | 1241 |
1240 int inlined_count = data->InlinedFunctionCount()->value(); | 1242 int inlined_count = data->InlinedFunctionCount()->value(); |
1241 for (int i = 0; i < inlined_count; ++i) { | 1243 for (int i = 0; i < inlined_count; ++i) { |
1242 JSFunction* inlined = JSFunction::cast(literals->get(i)); | 1244 JSFunction* inlined = JSFunction::cast(literals->get(i)); |
1243 if (inlined->shared() == candidate) return true; | 1245 if (inlined->shared() == candidate) return true; |
1244 } | 1246 } |
1245 | 1247 |
1246 return false; | 1248 return false; |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1542 position_change_array); | 1544 position_change_array); |
1543 int new_function_end = TranslatePosition(info->end_position(), | 1545 int new_function_end = TranslatePosition(info->end_position(), |
1544 position_change_array); | 1546 position_change_array); |
1545 int new_function_token_pos = | 1547 int new_function_token_pos = |
1546 TranslatePosition(info->function_token_position(), position_change_array); | 1548 TranslatePosition(info->function_token_position(), position_change_array); |
1547 | 1549 |
1548 info->set_start_position(new_function_start); | 1550 info->set_start_position(new_function_start); |
1549 info->set_end_position(new_function_end); | 1551 info->set_end_position(new_function_end); |
1550 info->set_function_token_position(new_function_token_pos); | 1552 info->set_function_token_position(new_function_token_pos); |
1551 | 1553 |
1552 HEAP->EnsureHeapIsIterable(); | 1554 info->GetIsolate()->heap()->EnsureHeapIsIterable(); |
1553 | 1555 |
1554 if (IsJSFunctionCode(info->code())) { | 1556 if (IsJSFunctionCode(info->code())) { |
1555 // Patch relocation info section of the code. | 1557 // Patch relocation info section of the code. |
1556 Handle<Code> patched_code = PatchPositionsInCode(Handle<Code>(info->code()), | 1558 Handle<Code> patched_code = PatchPositionsInCode(Handle<Code>(info->code()), |
1557 position_change_array); | 1559 position_change_array); |
1558 if (*patched_code != info->code()) { | 1560 if (*patched_code != info->code()) { |
1559 // Replace all references to the code across the heap. In particular, | 1561 // Replace all references to the code across the heap. In particular, |
1560 // some stubs may refer to this code and this code may be being executed | 1562 // some stubs may refer to this code and this code may be being executed |
1561 // on stack (it is safe to substitute the code object on stack, because | 1563 // on stack (it is safe to substitute the code object on stack, because |
1562 // we only change the structure of rinfo and leave instructions | 1564 // we only change the structure of rinfo and leave instructions |
1563 // untouched). | 1565 // untouched). |
1564 ReplaceCodeObject(Handle<Code>(info->code()), patched_code); | 1566 ReplaceCodeObject(Handle<Code>(info->code()), patched_code); |
1565 } | 1567 } |
1566 } | 1568 } |
1567 | 1569 |
1568 return HEAP->undefined_value(); | 1570 return info->GetIsolate()->heap()->undefined_value(); |
1569 } | 1571 } |
1570 | 1572 |
1571 | 1573 |
1572 static Handle<Script> CreateScriptCopy(Handle<Script> original) { | 1574 static Handle<Script> CreateScriptCopy(Handle<Script> original) { |
1573 Isolate* isolate = original->GetIsolate(); | 1575 Isolate* isolate = original->GetIsolate(); |
1574 | 1576 |
1575 Handle<String> original_source(String::cast(original->source())); | 1577 Handle<String> original_source(String::cast(original->source())); |
1576 Handle<Script> copy = isolate->factory()->NewScript(original_source); | 1578 Handle<Script> copy = isolate->factory()->NewScript(original_source); |
1577 | 1579 |
1578 copy->set_name(original->name()); | 1580 copy->set_name(original->name()); |
(...skipping 25 matching lines...) Expand all Loading... |
1604 old_script_object = old_script; | 1606 old_script_object = old_script; |
1605 isolate->debugger()->OnAfterCompile( | 1607 isolate->debugger()->OnAfterCompile( |
1606 old_script, Debugger::SEND_WHEN_DEBUGGING); | 1608 old_script, Debugger::SEND_WHEN_DEBUGGING); |
1607 } else { | 1609 } else { |
1608 old_script_object = isolate->factory()->null_value(); | 1610 old_script_object = isolate->factory()->null_value(); |
1609 } | 1611 } |
1610 | 1612 |
1611 original_script->set_source(*new_source); | 1613 original_script->set_source(*new_source); |
1612 | 1614 |
1613 // Drop line ends so that they will be recalculated. | 1615 // Drop line ends so that they will be recalculated. |
1614 original_script->set_line_ends(HEAP->undefined_value()); | 1616 original_script->set_line_ends(isolate->heap()->undefined_value()); |
1615 | 1617 |
1616 return *old_script_object; | 1618 return *old_script_object; |
1617 } | 1619 } |
1618 | 1620 |
1619 | 1621 |
1620 | 1622 |
1621 void LiveEdit::ReplaceRefToNestedFunction( | 1623 void LiveEdit::ReplaceRefToNestedFunction( |
1622 Handle<JSValue> parent_function_wrapper, | 1624 Handle<JSValue> parent_function_wrapper, |
1623 Handle<JSValue> orig_function_wrapper, | 1625 Handle<JSValue> orig_function_wrapper, |
1624 Handle<JSValue> subst_function_wrapper) { | 1626 Handle<JSValue> subst_function_wrapper) { |
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2152 | 2154 |
2153 bool LiveEditFunctionTracker::IsActive(Isolate* isolate) { | 2155 bool LiveEditFunctionTracker::IsActive(Isolate* isolate) { |
2154 return false; | 2156 return false; |
2155 } | 2157 } |
2156 | 2158 |
2157 #endif // ENABLE_DEBUGGER_SUPPORT | 2159 #endif // ENABLE_DEBUGGER_SUPPORT |
2158 | 2160 |
2159 | 2161 |
2160 | 2162 |
2161 } } // namespace v8::internal | 2163 } } // namespace v8::internal |
OLD | NEW |