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 28 matching lines...) Expand all Loading... |
39 | 39 |
40 | 40 |
41 const int Deoptimizer::table_entry_size_ = 10; | 41 const int Deoptimizer::table_entry_size_ = 10; |
42 | 42 |
43 | 43 |
44 int Deoptimizer::patch_size() { | 44 int Deoptimizer::patch_size() { |
45 return Assembler::kCallInstructionLength; | 45 return Assembler::kCallInstructionLength; |
46 } | 46 } |
47 | 47 |
48 | 48 |
49 void Deoptimizer::DeoptimizeFunction(JSFunction* function) { | 49 void Deoptimizer::DeoptimizeFunctionWithPreparedFunctionList( |
50 HandleScope scope; | 50 JSFunction* function) { |
| 51 Isolate* isolate = function->GetIsolate(); |
| 52 HandleScope scope(isolate); |
51 AssertNoAllocation no_allocation; | 53 AssertNoAllocation no_allocation; |
52 | 54 |
53 if (!function->IsOptimized()) return; | 55 ASSERT(function->IsOptimized()); |
| 56 ASSERT(function->FunctionsInFunctionListShareSameCode()); |
54 | 57 |
55 // The optimized code is going to be patched, so we cannot use it | 58 // The optimized code is going to be patched, so we cannot use it |
56 // any more. Play safe and reset the whole cache. | 59 // any more. Play safe and reset the whole cache. |
57 function->shared()->ClearOptimizedCodeMap(); | 60 function->shared()->ClearOptimizedCodeMap(); |
58 | 61 |
59 // Get the optimized code. | 62 // Get the optimized code. |
60 Code* code = function->code(); | 63 Code* code = function->code(); |
61 | 64 |
62 // Invalidate the relocation information, as it will become invalid by the | 65 // Invalidate the relocation information, as it will become invalid by the |
63 // code patching below, and is not needed any more. | 66 // code patching below, and is not needed any more. |
(...skipping 20 matching lines...) Expand all Loading... |
84 CodePatcher patcher(call_address, Assembler::kCallInstructionLength); | 87 CodePatcher patcher(call_address, Assembler::kCallInstructionLength); |
85 patcher.masm()->Call(GetDeoptimizationEntry(i, LAZY), RelocInfo::NONE); | 88 patcher.masm()->Call(GetDeoptimizationEntry(i, LAZY), RelocInfo::NONE); |
86 ASSERT(prev_call_address == NULL || | 89 ASSERT(prev_call_address == NULL || |
87 call_address >= prev_call_address + patch_size()); | 90 call_address >= prev_call_address + patch_size()); |
88 ASSERT(call_address + patch_size() <= code->instruction_end()); | 91 ASSERT(call_address + patch_size() <= code->instruction_end()); |
89 #ifdef DEBUG | 92 #ifdef DEBUG |
90 prev_call_address = call_address; | 93 prev_call_address = call_address; |
91 #endif | 94 #endif |
92 } | 95 } |
93 | 96 |
94 Isolate* isolate = code->GetIsolate(); | |
95 | |
96 // Add the deoptimizing code to the list. | 97 // Add the deoptimizing code to the list. |
97 DeoptimizingCodeListNode* node = new DeoptimizingCodeListNode(code); | 98 DeoptimizingCodeListNode* node = new DeoptimizingCodeListNode(code); |
98 DeoptimizerData* data = isolate->deoptimizer_data(); | 99 DeoptimizerData* data = isolate->deoptimizer_data(); |
99 node->set_next(data->deoptimizing_code_list_); | 100 node->set_next(data->deoptimizing_code_list_); |
100 data->deoptimizing_code_list_ = node; | 101 data->deoptimizing_code_list_ = node; |
101 | 102 |
102 // We might be in the middle of incremental marking with compaction. | 103 // We might be in the middle of incremental marking with compaction. |
103 // Tell collector to treat this code object in a special way and | 104 // Tell collector to treat this code object in a special way and |
104 // ignore all slots that might have been recorded on it. | 105 // ignore all slots that might have been recorded on it. |
105 isolate->heap()->mark_compact_collector()->InvalidateCode(code); | 106 isolate->heap()->mark_compact_collector()->InvalidateCode(code); |
(...skipping 987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1093 } | 1094 } |
1094 __ bind(&done); | 1095 __ bind(&done); |
1095 } | 1096 } |
1096 | 1097 |
1097 #undef __ | 1098 #undef __ |
1098 | 1099 |
1099 | 1100 |
1100 } } // namespace v8::internal | 1101 } } // namespace v8::internal |
1101 | 1102 |
1102 #endif // V8_TARGET_ARCH_X64 | 1103 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |