OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "factory.h" | 5 #include "factory.h" |
6 | 6 |
7 #include "conversions.h" | 7 #include "conversions.h" |
8 #include "isolate-inl.h" | 8 #include "isolate-inl.h" |
9 #include "macro-assembler.h" | 9 #include "macro-assembler.h" |
10 | 10 |
(...skipping 1377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1388 isolate()->heap()->AllocateCode(object_size, immovable), | 1388 isolate()->heap()->AllocateCode(object_size, immovable), |
1389 Code); | 1389 Code); |
1390 } | 1390 } |
1391 | 1391 |
1392 | 1392 |
1393 Handle<Code> Factory::NewCode(const CodeDesc& desc, | 1393 Handle<Code> Factory::NewCode(const CodeDesc& desc, |
1394 Code::Flags flags, | 1394 Code::Flags flags, |
1395 Handle<Object> self_ref, | 1395 Handle<Object> self_ref, |
1396 bool immovable, | 1396 bool immovable, |
1397 bool crankshafted, | 1397 bool crankshafted, |
1398 int prologue_offset) { | 1398 int prologue_offset, |
| 1399 bool is_debug) { |
1399 Handle<ByteArray> reloc_info = NewByteArray(desc.reloc_size, TENURED); | 1400 Handle<ByteArray> reloc_info = NewByteArray(desc.reloc_size, TENURED); |
1400 Handle<ConstantPoolArray> constant_pool = | 1401 Handle<ConstantPoolArray> constant_pool = |
1401 desc.origin->NewConstantPool(isolate()); | 1402 desc.origin->NewConstantPool(isolate()); |
1402 | 1403 |
1403 // Compute size. | 1404 // Compute size. |
1404 int body_size = RoundUp(desc.instr_size, kObjectAlignment); | 1405 int body_size = RoundUp(desc.instr_size, kObjectAlignment); |
1405 int obj_size = Code::SizeFor(body_size); | 1406 int obj_size = Code::SizeFor(body_size); |
1406 | 1407 |
1407 Handle<Code> code = NewCodeRaw(obj_size, immovable); | 1408 Handle<Code> code = NewCodeRaw(obj_size, immovable); |
1408 ASSERT(!isolate()->code_range()->exists() || | 1409 ASSERT(!isolate()->code_range()->exists() || |
(...skipping 12 matching lines...) Expand all Loading... |
1421 code->set_is_crankshafted(crankshafted); | 1422 code->set_is_crankshafted(crankshafted); |
1422 code->set_deoptimization_data(*empty_fixed_array(), SKIP_WRITE_BARRIER); | 1423 code->set_deoptimization_data(*empty_fixed_array(), SKIP_WRITE_BARRIER); |
1423 code->set_raw_type_feedback_info(*undefined_value()); | 1424 code->set_raw_type_feedback_info(*undefined_value()); |
1424 code->set_next_code_link(*undefined_value()); | 1425 code->set_next_code_link(*undefined_value()); |
1425 code->set_handler_table(*empty_fixed_array(), SKIP_WRITE_BARRIER); | 1426 code->set_handler_table(*empty_fixed_array(), SKIP_WRITE_BARRIER); |
1426 code->set_prologue_offset(prologue_offset); | 1427 code->set_prologue_offset(prologue_offset); |
1427 if (code->kind() == Code::OPTIMIZED_FUNCTION) { | 1428 if (code->kind() == Code::OPTIMIZED_FUNCTION) { |
1428 code->set_marked_for_deoptimization(false); | 1429 code->set_marked_for_deoptimization(false); |
1429 } | 1430 } |
1430 | 1431 |
| 1432 if (is_debug) { |
| 1433 ASSERT(code->kind() == Code::FUNCTION); |
| 1434 code->set_has_debug_break_slots(true); |
| 1435 } |
| 1436 |
1431 desc.origin->PopulateConstantPool(*constant_pool); | 1437 desc.origin->PopulateConstantPool(*constant_pool); |
1432 code->set_constant_pool(*constant_pool); | 1438 code->set_constant_pool(*constant_pool); |
1433 | 1439 |
1434 if (code->kind() == Code::FUNCTION) { | |
1435 code->set_has_debug_break_slots(isolate()->debugger()->IsDebuggerActive()); | |
1436 } | |
1437 | |
1438 // Allow self references to created code object by patching the handle to | 1440 // Allow self references to created code object by patching the handle to |
1439 // point to the newly allocated Code object. | 1441 // point to the newly allocated Code object. |
1440 if (!self_ref.is_null()) *(self_ref.location()) = *code; | 1442 if (!self_ref.is_null()) *(self_ref.location()) = *code; |
1441 | 1443 |
1442 // Migrate generated code. | 1444 // Migrate generated code. |
1443 // The generated code can contain Object** values (typically from handles) | 1445 // The generated code can contain Object** values (typically from handles) |
1444 // that are dereferenced during the copy to point directly to the actual heap | 1446 // that are dereferenced during the copy to point directly to the actual heap |
1445 // objects. These pointers can include references to the code object itself, | 1447 // objects. These pointers can include references to the code object itself, |
1446 // through the self_reference parameter. | 1448 // through the self_reference parameter. |
1447 code->CopyFrom(desc); | 1449 code->CopyFrom(desc); |
(...skipping 882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2330 return Handle<Object>::null(); | 2332 return Handle<Object>::null(); |
2331 } | 2333 } |
2332 | 2334 |
2333 | 2335 |
2334 Handle<Object> Factory::ToBoolean(bool value) { | 2336 Handle<Object> Factory::ToBoolean(bool value) { |
2335 return value ? true_value() : false_value(); | 2337 return value ? true_value() : false_value(); |
2336 } | 2338 } |
2337 | 2339 |
2338 | 2340 |
2339 } } // namespace v8::internal | 2341 } } // namespace v8::internal |
OLD | NEW |