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 "src/factory.h" | 5 #include "src/factory.h" |
6 | 6 |
7 #include "src/allocation-site-scopes.h" | 7 #include "src/allocation-site-scopes.h" |
8 #include "src/base/bits.h" | 8 #include "src/base/bits.h" |
9 #include "src/conversions.h" | 9 #include "src/conversions.h" |
10 #include "src/isolate-inl.h" | 10 #include "src/isolate-inl.h" |
(...skipping 1409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1420 | 1420 |
1421 | 1421 |
1422 Handle<Code> Factory::NewCode(const CodeDesc& desc, | 1422 Handle<Code> Factory::NewCode(const CodeDesc& desc, |
1423 Code::Flags flags, | 1423 Code::Flags flags, |
1424 Handle<Object> self_ref, | 1424 Handle<Object> self_ref, |
1425 bool immovable, | 1425 bool immovable, |
1426 bool crankshafted, | 1426 bool crankshafted, |
1427 int prologue_offset, | 1427 int prologue_offset, |
1428 bool is_debug) { | 1428 bool is_debug) { |
1429 Handle<ByteArray> reloc_info = NewByteArray(desc.reloc_size, TENURED); | 1429 Handle<ByteArray> reloc_info = NewByteArray(desc.reloc_size, TENURED); |
1430 Handle<ConstantPoolArray> constant_pool = | 1430 Handle<ConstantPoolArray> constant_pool; |
1431 desc.origin->NewConstantPool(isolate()); | 1431 |
| 1432 if (FLAG_enable_ool_constant_pool) { |
| 1433 constant_pool = desc.origin->NewConstantPool(isolate()); |
| 1434 } |
1432 | 1435 |
1433 // Compute size. | 1436 // Compute size. |
1434 int body_size = RoundUp(desc.instr_size, kObjectAlignment); | 1437 int body_size = RoundUp(desc.instr_size, kObjectAlignment); |
1435 int obj_size = Code::SizeFor(body_size); | 1438 int obj_size = Code::SizeFor(body_size); |
1436 | 1439 |
1437 Handle<Code> code = NewCodeRaw(obj_size, immovable); | 1440 Handle<Code> code = NewCodeRaw(obj_size, immovable); |
1438 DCHECK(isolate()->code_range() == NULL || | 1441 DCHECK(isolate()->code_range() == NULL || |
1439 !isolate()->code_range()->valid() || | 1442 !isolate()->code_range()->valid() || |
1440 isolate()->code_range()->contains(code->address())); | 1443 isolate()->code_range()->contains(code->address())); |
1441 | 1444 |
1442 // The code object has not been fully initialized yet. We rely on the | 1445 // The code object has not been fully initialized yet. We rely on the |
1443 // fact that no allocation will happen from this point on. | 1446 // fact that no allocation will happen from this point on. |
1444 DisallowHeapAllocation no_gc; | 1447 DisallowHeapAllocation no_gc; |
1445 code->set_gc_metadata(Smi::FromInt(0)); | 1448 code->set_gc_metadata(Smi::FromInt(0)); |
1446 code->set_ic_age(isolate()->heap()->global_ic_age()); | 1449 code->set_ic_age(isolate()->heap()->global_ic_age()); |
1447 code->set_instruction_size(desc.instr_size); | 1450 code->set_instruction_size(desc.instr_size); |
1448 code->set_relocation_info(*reloc_info); | 1451 code->set_relocation_info(*reloc_info); |
1449 code->set_flags(flags); | 1452 code->set_flags(flags); |
1450 code->set_raw_kind_specific_flags1(0); | 1453 code->set_raw_kind_specific_flags1(0); |
1451 code->set_raw_kind_specific_flags2(0); | 1454 code->set_raw_kind_specific_flags2(0); |
1452 code->set_is_crankshafted(crankshafted); | 1455 code->set_is_crankshafted(crankshafted); |
1453 code->set_deoptimization_data(*empty_fixed_array(), SKIP_WRITE_BARRIER); | 1456 code->set_deoptimization_data(*empty_fixed_array(), SKIP_WRITE_BARRIER); |
1454 code->set_raw_type_feedback_info(Smi::FromInt(0)); | 1457 code->set_raw_type_feedback_info(Smi::FromInt(0)); |
1455 code->set_next_code_link(*undefined_value()); | 1458 code->set_next_code_link(*undefined_value()); |
1456 code->set_handler_table(*empty_fixed_array(), SKIP_WRITE_BARRIER); | 1459 code->set_handler_table(*empty_fixed_array(), SKIP_WRITE_BARRIER); |
1457 code->set_prologue_offset(prologue_offset); | 1460 code->set_prologue_offset(prologue_offset); |
| 1461 if (FLAG_enable_embedded_constant_pool) { |
| 1462 code->set_constant_pool_offset(desc.instr_size - desc.constant_pool_size); |
| 1463 } |
1458 if (code->kind() == Code::OPTIMIZED_FUNCTION) { | 1464 if (code->kind() == Code::OPTIMIZED_FUNCTION) { |
1459 code->set_marked_for_deoptimization(false); | 1465 code->set_marked_for_deoptimization(false); |
1460 } | 1466 } |
1461 | 1467 |
1462 if (is_debug) { | 1468 if (is_debug) { |
1463 DCHECK(code->kind() == Code::FUNCTION); | 1469 DCHECK(code->kind() == Code::FUNCTION); |
1464 code->set_has_debug_break_slots(true); | 1470 code->set_has_debug_break_slots(true); |
1465 } | 1471 } |
1466 | 1472 |
1467 desc.origin->PopulateConstantPool(*constant_pool); | 1473 if (FLAG_enable_ool_constant_pool) { |
1468 code->set_constant_pool(*constant_pool); | 1474 desc.origin->PopulateConstantPool(*constant_pool); |
| 1475 code->set_constant_pool(*constant_pool); |
| 1476 } |
1469 | 1477 |
1470 // Allow self references to created code object by patching the handle to | 1478 // Allow self references to created code object by patching the handle to |
1471 // point to the newly allocated Code object. | 1479 // point to the newly allocated Code object. |
1472 if (!self_ref.is_null()) *(self_ref.location()) = *code; | 1480 if (!self_ref.is_null()) *(self_ref.location()) = *code; |
1473 | 1481 |
1474 // Migrate generated code. | 1482 // Migrate generated code. |
1475 // The generated code can contain Object** values (typically from handles) | 1483 // The generated code can contain Object** values (typically from handles) |
1476 // that are dereferenced during the copy to point directly to the actual heap | 1484 // that are dereferenced during the copy to point directly to the actual heap |
1477 // objects. These pointers can include references to the code object itself, | 1485 // objects. These pointers can include references to the code object itself, |
1478 // through the self_reference parameter. | 1486 // through the self_reference parameter. |
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2321 return Handle<Object>::null(); | 2329 return Handle<Object>::null(); |
2322 } | 2330 } |
2323 | 2331 |
2324 | 2332 |
2325 Handle<Object> Factory::ToBoolean(bool value) { | 2333 Handle<Object> Factory::ToBoolean(bool value) { |
2326 return value ? true_value() : false_value(); | 2334 return value ? true_value() : false_value(); |
2327 } | 2335 } |
2328 | 2336 |
2329 | 2337 |
2330 } } // namespace v8::internal | 2338 } } // namespace v8::internal |
OLD | NEW |