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

Side by Side Diff: src/factory.cc

Issue 235153003: Handlify code allocation. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comments Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « src/factory.h ('k') | src/heap.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 "factory.h" 5 #include "factory.h"
6 6
7 #include "macro-assembler.h"
7 #include "isolate-inl.h" 8 #include "isolate-inl.h"
8 9
9 namespace v8 { 10 namespace v8 {
10 namespace internal { 11 namespace internal {
11 12
12 13
13 template<typename T> 14 template<typename T>
14 Handle<T> Factory::New(Handle<Map> map, AllocationSpace space) { 15 Handle<T> Factory::New(Handle<Map> map, AllocationSpace space) {
15 CALL_HEAP_FUNCTION( 16 CALL_HEAP_FUNCTION(
16 isolate(), 17 isolate(),
(...skipping 1250 matching lines...) Expand 10 before | Expand all | Expand 10 after
1267 1268
1268 1269
1269 Handle<JSObject> Factory::NewExternal(void* value) { 1270 Handle<JSObject> Factory::NewExternal(void* value) {
1270 Handle<Foreign> foreign = NewForeign(static_cast<Address>(value)); 1271 Handle<Foreign> foreign = NewForeign(static_cast<Address>(value));
1271 Handle<JSObject> external = NewJSObjectFromMap(external_map()); 1272 Handle<JSObject> external = NewJSObjectFromMap(external_map());
1272 external->SetInternalField(0, *foreign); 1273 external->SetInternalField(0, *foreign);
1273 return external; 1274 return external;
1274 } 1275 }
1275 1276
1276 1277
1278 Handle<Code> NewCodeHelper(Isolate* isolate, int object_size, bool immovable) {
1279 CALL_HEAP_FUNCTION(isolate,
1280 isolate->heap()->AllocateCode(object_size, immovable),
1281 Code);
1282 }
1283
1284
1277 Handle<Code> Factory::NewCode(const CodeDesc& desc, 1285 Handle<Code> Factory::NewCode(const CodeDesc& desc,
1278 Code::Flags flags, 1286 Code::Flags flags,
1279 Handle<Object> self_ref, 1287 Handle<Object> self_ref,
1280 bool immovable, 1288 bool immovable,
1281 bool crankshafted, 1289 bool crankshafted,
1282 int prologue_offset) { 1290 int prologue_offset) {
1283 CALL_HEAP_FUNCTION(isolate(), 1291 Handle<ByteArray> reloc_info = NewByteArray(desc.reloc_size, TENURED);
1284 isolate()->heap()->CreateCode( 1292 Handle<ConstantPoolArray> constant_pool =
1285 desc, flags, self_ref, immovable, crankshafted, 1293 desc.origin->NewConstantPool(isolate());
1286 prologue_offset), 1294
1287 Code); 1295 // Compute size.
1296 int body_size = RoundUp(desc.instr_size, kObjectAlignment);
1297 int obj_size = Code::SizeFor(body_size);
1298
1299 Handle<Code> code = NewCodeHelper(isolate(), obj_size, immovable);
1300 ASSERT(!isolate()->code_range()->exists() ||
1301 isolate()->code_range()->contains(code->address()));
1302
1303 // The code object has not been fully initialized yet. We rely on the
1304 // fact that no allocation will happen from this point on.
1305 DisallowHeapAllocation no_gc;
1306 code->set_gc_metadata(Smi::FromInt(0));
1307 code->set_ic_age(isolate()->heap()->global_ic_age());
1308 code->set_instruction_size(desc.instr_size);
1309 code->set_relocation_info(*reloc_info);
1310 code->set_flags(flags);
1311 code->set_raw_kind_specific_flags1(0);
1312 code->set_raw_kind_specific_flags2(0);
1313 code->set_is_crankshafted(crankshafted);
1314 code->set_deoptimization_data(*empty_fixed_array(), SKIP_WRITE_BARRIER);
1315 code->set_raw_type_feedback_info(*undefined_value());
1316 code->set_next_code_link(*undefined_value());
1317 code->set_handler_table(*empty_fixed_array(), SKIP_WRITE_BARRIER);
1318 code->set_prologue_offset(prologue_offset);
1319 if (code->kind() == Code::OPTIMIZED_FUNCTION) {
1320 code->set_marked_for_deoptimization(false);
1321 }
1322
1323 desc.origin->PopulateConstantPool(*constant_pool);
1324 code->set_constant_pool(*constant_pool);
1325
1326 #ifdef ENABLE_DEBUGGER_SUPPORT
1327 if (code->kind() == Code::FUNCTION) {
1328 code->set_has_debug_break_slots(isolate()->debugger()->IsDebuggerActive());
1329 }
1330 #endif
1331
1332 // Allow self references to created code object by patching the handle to
1333 // point to the newly allocated Code object.
1334 if (!self_ref.is_null()) *(self_ref.location()) = *code;
1335
1336 // Migrate generated code.
1337 // The generated code can contain Object** values (typically from handles)
1338 // that are dereferenced during the copy to point directly to the actual heap
1339 // objects. These pointers can include references to the code object itself,
1340 // through the self_reference parameter.
1341 code->CopyFrom(desc);
1342
1343 #ifdef VERIFY_HEAP
1344 if (FLAG_verify_heap) {
1345 code->Verify();
1346 }
1347 #endif
1348 return code;
1288 } 1349 }
1289 1350
1290 1351
1291 Handle<Code> Factory::CopyCode(Handle<Code> code) { 1352 Handle<Code> Factory::CopyCode(Handle<Code> code) {
1292 CALL_HEAP_FUNCTION(isolate(), 1353 CALL_HEAP_FUNCTION(isolate(),
1293 isolate()->heap()->CopyCode(*code), 1354 isolate()->heap()->CopyCode(*code),
1294 Code); 1355 Code);
1295 } 1356 }
1296 1357
1297 1358
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after
2097 if (String::Equals(name, infinity_string())) return infinity_value(); 2158 if (String::Equals(name, infinity_string())) return infinity_value();
2098 return Handle<Object>::null(); 2159 return Handle<Object>::null();
2099 } 2160 }
2100 2161
2101 2162
2102 Handle<Object> Factory::ToBoolean(bool value) { 2163 Handle<Object> Factory::ToBoolean(bool value) {
2103 return value ? true_value() : false_value(); 2164 return value ? true_value() : false_value();
2104 } 2165 }
2105 2166
2106 } } // namespace v8::internal 2167 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/factory.h ('k') | src/heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698