| 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 "macro-assembler.h" | 7 #include "macro-assembler.h" |
| 8 #include "isolate-inl.h" | 8 #include "isolate-inl.h" |
| 9 #include "v8conversions.h" | 9 #include "v8conversions.h" |
| 10 | 10 |
| (...skipping 1310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1321 | 1321 |
| 1322 | 1322 |
| 1323 Handle<JSObject> Factory::NewExternal(void* value) { | 1323 Handle<JSObject> Factory::NewExternal(void* value) { |
| 1324 Handle<Foreign> foreign = NewForeign(static_cast<Address>(value)); | 1324 Handle<Foreign> foreign = NewForeign(static_cast<Address>(value)); |
| 1325 Handle<JSObject> external = NewJSObjectFromMap(external_map()); | 1325 Handle<JSObject> external = NewJSObjectFromMap(external_map()); |
| 1326 external->SetInternalField(0, *foreign); | 1326 external->SetInternalField(0, *foreign); |
| 1327 return external; | 1327 return external; |
| 1328 } | 1328 } |
| 1329 | 1329 |
| 1330 | 1330 |
| 1331 Handle<Code> NewCodeHelper(Isolate* isolate, int object_size, bool immovable) { | 1331 Handle<Code> Factory::NewCodeHelper(int object_size, bool immovable) { |
| 1332 CALL_HEAP_FUNCTION(isolate, | 1332 CALL_HEAP_FUNCTION(isolate(), |
| 1333 isolate->heap()->AllocateCode(object_size, immovable), | 1333 isolate()->heap()->AllocateCode(object_size, immovable), |
| 1334 Code); | 1334 Code); |
| 1335 } | 1335 } |
| 1336 | 1336 |
| 1337 | 1337 |
| 1338 Handle<Code> Factory::NewCode(const CodeDesc& desc, | 1338 Handle<Code> Factory::NewCode(const CodeDesc& desc, |
| 1339 Code::Flags flags, | 1339 Code::Flags flags, |
| 1340 Handle<Object> self_ref, | 1340 Handle<Object> self_ref, |
| 1341 bool immovable, | 1341 bool immovable, |
| 1342 bool crankshafted, | 1342 bool crankshafted, |
| 1343 int prologue_offset) { | 1343 int prologue_offset) { |
| 1344 Handle<ByteArray> reloc_info = NewByteArray(desc.reloc_size, TENURED); | 1344 Handle<ByteArray> reloc_info = NewByteArray(desc.reloc_size, TENURED); |
| 1345 Handle<ConstantPoolArray> constant_pool = | 1345 Handle<ConstantPoolArray> constant_pool = |
| 1346 desc.origin->NewConstantPool(isolate()); | 1346 desc.origin->NewConstantPool(isolate()); |
| 1347 | 1347 |
| 1348 // Compute size. | 1348 // Compute size. |
| 1349 int body_size = RoundUp(desc.instr_size, kObjectAlignment); | 1349 int body_size = RoundUp(desc.instr_size, kObjectAlignment); |
| 1350 int obj_size = Code::SizeFor(body_size); | 1350 int obj_size = Code::SizeFor(body_size); |
| 1351 | 1351 |
| 1352 Handle<Code> code = NewCodeHelper(isolate(), obj_size, immovable); | 1352 Handle<Code> code = NewCodeHelper(obj_size, immovable); |
| 1353 ASSERT(!isolate()->code_range()->exists() || | 1353 ASSERT(!isolate()->code_range()->exists() || |
| 1354 isolate()->code_range()->contains(code->address())); | 1354 isolate()->code_range()->contains(code->address())); |
| 1355 | 1355 |
| 1356 // The code object has not been fully initialized yet. We rely on the | 1356 // The code object has not been fully initialized yet. We rely on the |
| 1357 // fact that no allocation will happen from this point on. | 1357 // fact that no allocation will happen from this point on. |
| 1358 DisallowHeapAllocation no_gc; | 1358 DisallowHeapAllocation no_gc; |
| 1359 code->set_gc_metadata(Smi::FromInt(0)); | 1359 code->set_gc_metadata(Smi::FromInt(0)); |
| 1360 code->set_ic_age(isolate()->heap()->global_ic_age()); | 1360 code->set_ic_age(isolate()->heap()->global_ic_age()); |
| 1361 code->set_instruction_size(desc.instr_size); | 1361 code->set_instruction_size(desc.instr_size); |
| 1362 code->set_relocation_info(*reloc_info); | 1362 code->set_relocation_info(*reloc_info); |
| (...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2327 return Handle<Object>::null(); | 2327 return Handle<Object>::null(); |
| 2328 } | 2328 } |
| 2329 | 2329 |
| 2330 | 2330 |
| 2331 Handle<Object> Factory::ToBoolean(bool value) { | 2331 Handle<Object> Factory::ToBoolean(bool value) { |
| 2332 return value ? true_value() : false_value(); | 2332 return value ? true_value() : false_value(); |
| 2333 } | 2333 } |
| 2334 | 2334 |
| 2335 | 2335 |
| 2336 } } // namespace v8::internal | 2336 } } // namespace v8::internal |
| OLD | NEW |