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/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/conversions.h" | 10 #include "src/conversions.h" |
(...skipping 1409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1420 Handle<Code> Factory::NewCode(const CodeDesc& desc, | 1420 Handle<Code> Factory::NewCode(const CodeDesc& desc, |
1421 Code::Flags flags, | 1421 Code::Flags flags, |
1422 Handle<Object> self_ref, | 1422 Handle<Object> self_ref, |
1423 bool immovable, | 1423 bool immovable, |
1424 bool crankshafted, | 1424 bool crankshafted, |
1425 int prologue_offset, | 1425 int prologue_offset, |
1426 bool is_debug) { | 1426 bool is_debug) { |
1427 Handle<ByteArray> reloc_info = NewByteArray(desc.reloc_size, TENURED); | 1427 Handle<ByteArray> reloc_info = NewByteArray(desc.reloc_size, TENURED); |
1428 | 1428 |
1429 // Compute size. | 1429 // Compute size. |
1430 int body_size = RoundUp(desc.instr_size, kObjectAlignment); | 1430 int unpadded_body_size = desc.unwinding_info_size > 0 |
rmcilroy
2016/06/21 13:47:43
nit - just body_size (the RoundUp at the end isn't
rmcilroy
2016/06/21 13:47:43
Create a local variable for has_unwinding_info and
Stefano Sanfilippo
2016/06/23 15:23:43
Done.
Stefano Sanfilippo
2016/06/23 15:23:43
Done.
| |
1431 ? RoundUp(desc.instr_size, kInt64Size) + | |
1432 desc.unwinding_info_size + kInt64Size | |
rmcilroy
2016/06/21 13:47:43
Do this addition in an if block (setting body_size
Stefano Sanfilippo
2016/06/23 15:23:43
Done.
| |
1433 : desc.instr_size; | |
1434 int body_size = RoundUp(unpadded_body_size, kObjectAlignment); | |
1431 int obj_size = Code::SizeFor(body_size); | 1435 int obj_size = Code::SizeFor(body_size); |
1432 | 1436 |
1433 Handle<Code> code = NewCodeRaw(obj_size, immovable); | 1437 Handle<Code> code = NewCodeRaw(obj_size, immovable); |
1434 DCHECK(!isolate()->heap()->memory_allocator()->code_range()->valid() || | 1438 DCHECK(!isolate()->heap()->memory_allocator()->code_range()->valid() || |
1435 isolate()->heap()->memory_allocator()->code_range()->contains( | 1439 isolate()->heap()->memory_allocator()->code_range()->contains( |
1436 code->address()) || | 1440 code->address()) || |
1437 obj_size <= isolate()->heap()->code_space()->AreaSize()); | 1441 obj_size <= isolate()->heap()->code_space()->AreaSize()); |
1438 | 1442 |
1439 // The code object has not been fully initialized yet. We rely on the | 1443 // The code object has not been fully initialized yet. We rely on the |
1440 // fact that no allocation will happen from this point on. | 1444 // fact that no allocation will happen from this point on. |
1441 DisallowHeapAllocation no_gc; | 1445 DisallowHeapAllocation no_gc; |
1442 code->set_gc_metadata(Smi::FromInt(0)); | 1446 code->set_gc_metadata(Smi::FromInt(0)); |
1443 code->set_ic_age(isolate()->heap()->global_ic_age()); | 1447 code->set_ic_age(isolate()->heap()->global_ic_age()); |
1444 code->set_instruction_size(desc.instr_size); | 1448 code->set_instruction_size(desc.instr_size); |
1445 code->set_relocation_info(*reloc_info); | 1449 code->set_relocation_info(*reloc_info); |
1446 code->set_flags(flags); | 1450 code->set_flags(flags); |
1451 code->set_has_unwinding_info(desc.unwinding_info_size > 0); | |
1447 code->set_raw_kind_specific_flags1(0); | 1452 code->set_raw_kind_specific_flags1(0); |
1448 code->set_raw_kind_specific_flags2(0); | 1453 code->set_raw_kind_specific_flags2(0); |
1449 code->set_is_crankshafted(crankshafted); | 1454 code->set_is_crankshafted(crankshafted); |
1450 code->set_deoptimization_data(*empty_fixed_array(), SKIP_WRITE_BARRIER); | 1455 code->set_deoptimization_data(*empty_fixed_array(), SKIP_WRITE_BARRIER); |
1451 code->set_raw_type_feedback_info(Smi::FromInt(0)); | 1456 code->set_raw_type_feedback_info(Smi::FromInt(0)); |
1452 code->set_next_code_link(*undefined_value()); | 1457 code->set_next_code_link(*undefined_value()); |
1453 code->set_handler_table(*empty_fixed_array(), SKIP_WRITE_BARRIER); | 1458 code->set_handler_table(*empty_fixed_array(), SKIP_WRITE_BARRIER); |
1454 code->set_prologue_offset(prologue_offset); | 1459 code->set_prologue_offset(prologue_offset); |
1455 code->set_constant_pool_offset(desc.instr_size - desc.constant_pool_size); | 1460 code->set_constant_pool_offset(desc.instr_size - desc.constant_pool_size); |
1456 | 1461 |
(...skipping 935 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2392 } | 2397 } |
2393 | 2398 |
2394 | 2399 |
2395 Handle<Object> Factory::ToBoolean(bool value) { | 2400 Handle<Object> Factory::ToBoolean(bool value) { |
2396 return value ? true_value() : false_value(); | 2401 return value ? true_value() : false_value(); |
2397 } | 2402 } |
2398 | 2403 |
2399 | 2404 |
2400 } // namespace internal | 2405 } // namespace internal |
2401 } // namespace v8 | 2406 } // namespace v8 |
OLD | NEW |