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

Side by Side Diff: src/factory.cc

Issue 227623002: Handlify ten allocator functions from the Heap. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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 "isolate-inl.h" 7 #include "isolate-inl.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
11 11
12 Handle<Box> Factory::NewBox(Handle<Object> value, PretenureFlag pretenure) { 12 Handle<Box> Factory::NewBox(Handle<Object> value) {
13 CALL_HEAP_FUNCTION( 13 Handle<Box> result = Handle<Box>::cast(NewStruct(BOX_TYPE));
14 isolate(), 14 result->set_value(*value);
15 isolate()->heap()->AllocateBox(*value, pretenure), 15 return result;
16 Box);
17 } 16 }
18 17
19 18
20 Handle<FixedArray> Factory::NewFixedArray(int size, PretenureFlag pretenure) { 19 Handle<FixedArray> Factory::NewFixedArray(int size, PretenureFlag pretenure) {
21 ASSERT(0 <= size); 20 ASSERT(0 <= size);
22 CALL_HEAP_FUNCTION( 21 CALL_HEAP_FUNCTION(
23 isolate(), 22 isolate(),
24 isolate()->heap()->AllocateFixedArray(size, pretenure), 23 isolate()->heap()->AllocateFixedArray(size, pretenure),
25 FixedArray); 24 FixedArray);
26 } 25 }
(...skipping 1260 matching lines...) Expand 10 before | Expand all | Expand 10 after
1287 JSFunction::EnsureHasInitialMap(constructor); 1286 JSFunction::EnsureHasInitialMap(constructor);
1288 CALL_HEAP_FUNCTION( 1287 CALL_HEAP_FUNCTION(
1289 isolate(), 1288 isolate(),
1290 isolate()->heap()->AllocateJSObject(*constructor, NOT_TENURED, *site), 1289 isolate()->heap()->AllocateJSObject(*constructor, NOT_TENURED, *site),
1291 JSObject); 1290 JSObject);
1292 } 1291 }
1293 1292
1294 1293
1295 Handle<JSModule> Factory::NewJSModule(Handle<Context> context, 1294 Handle<JSModule> Factory::NewJSModule(Handle<Context> context,
1296 Handle<ScopeInfo> scope_info) { 1295 Handle<ScopeInfo> scope_info) {
1297 CALL_HEAP_FUNCTION( 1296 // Allocate a fresh map. Modules do not have a prototype.
1298 isolate(), 1297 Handle<Map> map = NewMap(JS_MODULE_TYPE, JSModule::kSize);
1299 isolate()->heap()->AllocateJSModule(*context, *scope_info), JSModule); 1298 // Allocate the object based on the map.
1299 Handle<JSModule> module =
1300 Handle<JSModule>::cast(NewJSObjectFromMap(map, TENURED));
1301 module->set_context(*context);
1302 module->set_scope_info(*scope_info);
1303 return module;
1300 } 1304 }
1301 1305
1302 1306
1303 // TODO(mstarzinger): Temporary wrapper until handlified. 1307 // TODO(mstarzinger): Temporary wrapper until handlified.
1304 static Handle<NameDictionary> NameDictionaryAdd(Handle<NameDictionary> dict, 1308 static Handle<NameDictionary> NameDictionaryAdd(Handle<NameDictionary> dict,
1305 Handle<Name> name, 1309 Handle<Name> name,
1306 Handle<Object> value, 1310 Handle<Object> value,
1307 PropertyDetails details) { 1311 PropertyDetails details) {
1308 CALL_HEAP_FUNCTION(dict->GetIsolate(), 1312 CALL_HEAP_FUNCTION(dict->GetIsolate(),
1309 dict->Add(*name, *value, details), 1313 dict->Add(*name, *value, details),
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1385 *map, 1389 *map,
1386 pretenure, 1390 pretenure,
1387 alloc_props, 1391 alloc_props,
1388 allocation_site.is_null() ? NULL : *allocation_site), 1392 allocation_site.is_null() ? NULL : *allocation_site),
1389 JSObject); 1393 JSObject);
1390 } 1394 }
1391 1395
1392 1396
1393 Handle<JSArray> Factory::NewJSArray(ElementsKind elements_kind, 1397 Handle<JSArray> Factory::NewJSArray(ElementsKind elements_kind,
1394 PretenureFlag pretenure) { 1398 PretenureFlag pretenure) {
1395 CALL_HEAP_FUNCTION(isolate(), 1399 Context* native_context = isolate()->context()->native_context();
1396 isolate()->heap()->AllocateJSArray(elements_kind, 1400 JSFunction* array_function = native_context->array_function();
1397 pretenure), 1401 Map* map = array_function->initial_map();
1398 JSArray); 1402 Map* transition_map = isolate()->get_initial_js_array_map(elements_kind);
1403 if (transition_map != NULL) map = transition_map;
1404 return Handle<JSArray>::cast(NewJSObjectFromMap(handle(map), pretenure));
1399 } 1405 }
1400 1406
1401 1407
1402 Handle<JSArray> Factory::NewJSArray(ElementsKind elements_kind, 1408 Handle<JSArray> Factory::NewJSArray(ElementsKind elements_kind,
1403 int length, 1409 int length,
1404 int capacity, 1410 int capacity,
1405 ArrayStorageAllocationMode mode, 1411 ArrayStorageAllocationMode mode,
1406 PretenureFlag pretenure) { 1412 PretenureFlag pretenure) {
1407 CALL_HEAP_FUNCTION(isolate(), 1413 Handle<JSArray> array = NewJSArray(elements_kind, pretenure);
1408 isolate()->heap()->AllocateJSArrayAndStorage( 1414 NewJSArrayStorage(array, length, capacity, mode);
1409 elements_kind, 1415 return array;
1410 length,
1411 capacity,
1412 mode,
1413 pretenure),
1414 JSArray);
1415 } 1416 }
1416 1417
1417 1418
1418 Handle<JSArray> Factory::NewJSArrayWithElements(Handle<FixedArrayBase> elements, 1419 Handle<JSArray> Factory::NewJSArrayWithElements(Handle<FixedArrayBase> elements,
1419 ElementsKind elements_kind, 1420 ElementsKind elements_kind,
1420 int length, 1421 int length,
1421 PretenureFlag pretenure) { 1422 PretenureFlag pretenure) {
1422 ASSERT(length <= elements->length()); 1423 ASSERT(length <= elements->length());
1423 Handle<JSArray> array = 1424 Handle<JSArray> array =
1424 isolate()->factory()->NewJSArray(elements_kind, pretenure); 1425 isolate()->factory()->NewJSArray(elements_kind, pretenure);
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
1978 if (name->Equals(h->infinity_string())) return infinity_value(); 1979 if (name->Equals(h->infinity_string())) return infinity_value();
1979 return Handle<Object>::null(); 1980 return Handle<Object>::null();
1980 } 1981 }
1981 1982
1982 1983
1983 Handle<Object> Factory::ToBoolean(bool value) { 1984 Handle<Object> Factory::ToBoolean(bool value) {
1984 return value ? true_value() : false_value(); 1985 return value ? true_value() : false_value();
1985 } 1986 }
1986 1987
1987 } } // namespace v8::internal 1988 } } // 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