Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(522)

Side by Side Diff: src/factory.cc

Issue 1131783003: Embedded constant pools. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix debug-mode Arm issue. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/factory.h ('k') | src/flag-definitions.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 Handle<FixedDoubleArray> double_array = 119 Handle<FixedDoubleArray> double_array =
120 Handle<FixedDoubleArray>::cast(array); 120 Handle<FixedDoubleArray>::cast(array);
121 for (int i = 0; i < size; ++i) { 121 for (int i = 0; i < size; ++i) {
122 double_array->set_the_hole(i); 122 double_array->set_the_hole(i);
123 } 123 }
124 } 124 }
125 return array; 125 return array;
126 } 126 }
127 127
128 128
129 Handle<ConstantPoolArray> Factory::NewConstantPoolArray(
130 const ConstantPoolArray::NumberOfEntries& small) {
131 DCHECK(small.total_count() > 0);
132 CALL_HEAP_FUNCTION(
133 isolate(),
134 isolate()->heap()->AllocateConstantPoolArray(small),
135 ConstantPoolArray);
136 }
137
138
139 Handle<ConstantPoolArray> Factory::NewExtendedConstantPoolArray(
140 const ConstantPoolArray::NumberOfEntries& small,
141 const ConstantPoolArray::NumberOfEntries& extended) {
142 DCHECK(small.total_count() > 0);
143 DCHECK(extended.total_count() > 0);
144 CALL_HEAP_FUNCTION(
145 isolate(),
146 isolate()->heap()->AllocateExtendedConstantPoolArray(small, extended),
147 ConstantPoolArray);
148 }
149
150
151 Handle<OrderedHashSet> Factory::NewOrderedHashSet() { 129 Handle<OrderedHashSet> Factory::NewOrderedHashSet() {
152 return OrderedHashSet::Allocate(isolate(), OrderedHashSet::kMinCapacity); 130 return OrderedHashSet::Allocate(isolate(), OrderedHashSet::kMinCapacity);
153 } 131 }
154 132
155 133
156 Handle<OrderedHashMap> Factory::NewOrderedHashMap() { 134 Handle<OrderedHashMap> Factory::NewOrderedHashMap() {
157 return OrderedHashMap::Allocate(isolate(), OrderedHashMap::kMinCapacity); 135 return OrderedHashMap::Allocate(isolate(), OrderedHashMap::kMinCapacity);
158 } 136 }
159 137
160 138
(...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 999
1022 1000
1023 Handle<FixedDoubleArray> Factory::CopyFixedDoubleArray( 1001 Handle<FixedDoubleArray> Factory::CopyFixedDoubleArray(
1024 Handle<FixedDoubleArray> array) { 1002 Handle<FixedDoubleArray> array) {
1025 CALL_HEAP_FUNCTION(isolate(), 1003 CALL_HEAP_FUNCTION(isolate(),
1026 isolate()->heap()->CopyFixedDoubleArray(*array), 1004 isolate()->heap()->CopyFixedDoubleArray(*array),
1027 FixedDoubleArray); 1005 FixedDoubleArray);
1028 } 1006 }
1029 1007
1030 1008
1031 Handle<ConstantPoolArray> Factory::CopyConstantPoolArray(
1032 Handle<ConstantPoolArray> array) {
1033 CALL_HEAP_FUNCTION(isolate(),
1034 isolate()->heap()->CopyConstantPoolArray(*array),
1035 ConstantPoolArray);
1036 }
1037
1038
1039 Handle<Object> Factory::NewNumber(double value, 1009 Handle<Object> Factory::NewNumber(double value,
1040 PretenureFlag pretenure) { 1010 PretenureFlag pretenure) {
1041 // We need to distinguish the minus zero value and this cannot be 1011 // We need to distinguish the minus zero value and this cannot be
1042 // done after conversion to int. Doing this by comparing bit 1012 // done after conversion to int. Doing this by comparing bit
1043 // patterns is faster than using fpclassify() et al. 1013 // patterns is faster than using fpclassify() et al.
1044 if (IsMinusZero(value)) return NewHeapNumber(-0.0, IMMUTABLE, pretenure); 1014 if (IsMinusZero(value)) return NewHeapNumber(-0.0, IMMUTABLE, pretenure);
1045 1015
1046 int int_value = FastD2IChecked(value); 1016 int int_value = FastD2IChecked(value);
1047 if (value == int_value && Smi::IsValid(int_value)) { 1017 if (value == int_value && Smi::IsValid(int_value)) {
1048 return handle(Smi::FromInt(int_value), isolate()); 1018 return handle(Smi::FromInt(int_value), isolate());
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
1449 1419
1450 1420
1451 Handle<Code> Factory::NewCode(const CodeDesc& desc, 1421 Handle<Code> Factory::NewCode(const CodeDesc& desc,
1452 Code::Flags flags, 1422 Code::Flags flags,
1453 Handle<Object> self_ref, 1423 Handle<Object> self_ref,
1454 bool immovable, 1424 bool immovable,
1455 bool crankshafted, 1425 bool crankshafted,
1456 int prologue_offset, 1426 int prologue_offset,
1457 bool is_debug) { 1427 bool is_debug) {
1458 Handle<ByteArray> reloc_info = NewByteArray(desc.reloc_size, TENURED); 1428 Handle<ByteArray> reloc_info = NewByteArray(desc.reloc_size, TENURED);
1459 Handle<ConstantPoolArray> constant_pool =
1460 desc.origin->NewConstantPool(isolate());
1461 1429
1462 // Compute size. 1430 // Compute size.
1463 int body_size = RoundUp(desc.instr_size, kObjectAlignment); 1431 int body_size = RoundUp(desc.instr_size, kObjectAlignment);
1464 int obj_size = Code::SizeFor(body_size); 1432 int obj_size = Code::SizeFor(body_size);
1465 1433
1466 Handle<Code> code = NewCodeRaw(obj_size, immovable); 1434 Handle<Code> code = NewCodeRaw(obj_size, immovable);
1467 DCHECK(isolate()->code_range() == NULL || 1435 DCHECK(isolate()->code_range() == NULL ||
1468 !isolate()->code_range()->valid() || 1436 !isolate()->code_range()->valid() ||
1469 isolate()->code_range()->contains(code->address())); 1437 isolate()->code_range()->contains(code->address()));
1470 1438
1471 // The code object has not been fully initialized yet. We rely on the 1439 // The code object has not been fully initialized yet. We rely on the
1472 // fact that no allocation will happen from this point on. 1440 // fact that no allocation will happen from this point on.
1473 DisallowHeapAllocation no_gc; 1441 DisallowHeapAllocation no_gc;
1474 code->set_gc_metadata(Smi::FromInt(0)); 1442 code->set_gc_metadata(Smi::FromInt(0));
1475 code->set_ic_age(isolate()->heap()->global_ic_age()); 1443 code->set_ic_age(isolate()->heap()->global_ic_age());
1476 code->set_instruction_size(desc.instr_size); 1444 code->set_instruction_size(desc.instr_size);
1477 code->set_relocation_info(*reloc_info); 1445 code->set_relocation_info(*reloc_info);
1478 code->set_flags(flags); 1446 code->set_flags(flags);
1479 code->set_raw_kind_specific_flags1(0); 1447 code->set_raw_kind_specific_flags1(0);
1480 code->set_raw_kind_specific_flags2(0); 1448 code->set_raw_kind_specific_flags2(0);
1481 code->set_is_crankshafted(crankshafted); 1449 code->set_is_crankshafted(crankshafted);
1482 code->set_deoptimization_data(*empty_fixed_array(), SKIP_WRITE_BARRIER); 1450 code->set_deoptimization_data(*empty_fixed_array(), SKIP_WRITE_BARRIER);
1483 code->set_raw_type_feedback_info(Smi::FromInt(0)); 1451 code->set_raw_type_feedback_info(Smi::FromInt(0));
1484 code->set_next_code_link(*undefined_value()); 1452 code->set_next_code_link(*undefined_value());
1485 code->set_handler_table(*empty_fixed_array(), SKIP_WRITE_BARRIER); 1453 code->set_handler_table(*empty_fixed_array(), SKIP_WRITE_BARRIER);
1486 code->set_prologue_offset(prologue_offset); 1454 code->set_prologue_offset(prologue_offset);
1455 if (FLAG_enable_embedded_constant_pool) {
1456 code->set_constant_pool_offset(desc.instr_size - desc.constant_pool_size);
1457 }
1487 if (code->kind() == Code::OPTIMIZED_FUNCTION) { 1458 if (code->kind() == Code::OPTIMIZED_FUNCTION) {
1488 code->set_marked_for_deoptimization(false); 1459 code->set_marked_for_deoptimization(false);
1489 } 1460 }
1490 1461
1491 if (is_debug) { 1462 if (is_debug) {
1492 DCHECK(code->kind() == Code::FUNCTION); 1463 DCHECK(code->kind() == Code::FUNCTION);
1493 code->set_has_debug_break_slots(true); 1464 code->set_has_debug_break_slots(true);
1494 } 1465 }
1495 1466
1496 desc.origin->PopulateConstantPool(*constant_pool);
1497 code->set_constant_pool(*constant_pool);
1498
1499 // Allow self references to created code object by patching the handle to 1467 // Allow self references to created code object by patching the handle to
1500 // point to the newly allocated Code object. 1468 // point to the newly allocated Code object.
1501 if (!self_ref.is_null()) *(self_ref.location()) = *code; 1469 if (!self_ref.is_null()) *(self_ref.location()) = *code;
1502 1470
1503 // Migrate generated code. 1471 // Migrate generated code.
1504 // The generated code can contain Object** values (typically from handles) 1472 // The generated code can contain Object** values (typically from handles)
1505 // that are dereferenced during the copy to point directly to the actual heap 1473 // that are dereferenced during the copy to point directly to the actual heap
1506 // objects. These pointers can include references to the code object itself, 1474 // objects. These pointers can include references to the code object itself,
1507 // through the self_reference parameter. 1475 // through the self_reference parameter.
1508 code->CopyFrom(desc); 1476 code->CopyFrom(desc);
(...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after
2459 } 2427 }
2460 2428
2461 2429
2462 Handle<Object> Factory::ToBoolean(bool value) { 2430 Handle<Object> Factory::ToBoolean(bool value) {
2463 return value ? true_value() : false_value(); 2431 return value ? true_value() : false_value();
2464 } 2432 }
2465 2433
2466 2434
2467 } // namespace internal 2435 } // namespace internal
2468 } // namespace v8 2436 } // namespace v8
OLDNEW
« no previous file with comments | « src/factory.h ('k') | src/flag-definitions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698