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

Side by Side Diff: src/factory.cc

Issue 236983002: Handlify Heap::AllocateJSArrayStorage and friends. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Some more follow-up work. 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 {
(...skipping 12 matching lines...) Expand all
23 isolate()->heap()->AllocateFixedArray(size, pretenure), 23 isolate()->heap()->AllocateFixedArray(size, pretenure),
24 FixedArray); 24 FixedArray);
25 } 25 }
26 26
27 27
28 Handle<FixedArray> Factory::NewFixedArrayWithHoles(int size, 28 Handle<FixedArray> Factory::NewFixedArrayWithHoles(int size,
29 PretenureFlag pretenure) { 29 PretenureFlag pretenure) {
30 ASSERT(0 <= size); 30 ASSERT(0 <= size);
31 CALL_HEAP_FUNCTION( 31 CALL_HEAP_FUNCTION(
32 isolate(), 32 isolate(),
33 isolate()->heap()->AllocateFixedArrayWithHoles(size, pretenure), 33 isolate()->heap()->AllocateFixedArrayWithFiller(size,
34 pretenure,
35 *the_hole_value()),
34 FixedArray); 36 FixedArray);
35 } 37 }
36 38
37 39
38 Handle<FixedArray> Factory::NewUninitializedFixedArray(int size) { 40 Handle<FixedArray> Factory::NewUninitializedFixedArray(int size) {
39 CALL_HEAP_FUNCTION( 41 CALL_HEAP_FUNCTION(
40 isolate(), 42 isolate(),
41 isolate()->heap()->AllocateUninitializedFixedArray(size), 43 isolate()->heap()->AllocateUninitializedFixedArray(size),
42 FixedArray); 44 FixedArray);
43 } 45 }
44 46
45 47
46 Handle<FixedDoubleArray> Factory::NewFixedDoubleArray(int size, 48 Handle<FixedDoubleArray> Factory::NewFixedDoubleArray(int size,
47 PretenureFlag pretenure) { 49 PretenureFlag pretenure) {
48 ASSERT(0 <= size); 50 ASSERT(0 <= size);
49 CALL_HEAP_FUNCTION( 51 CALL_HEAP_FUNCTION(
50 isolate(), 52 isolate(),
51 isolate()->heap()->AllocateUninitializedFixedDoubleArray(size, pretenure), 53 isolate()->heap()->AllocateUninitializedFixedDoubleArray(size, pretenure),
52 FixedDoubleArray); 54 FixedDoubleArray);
53 } 55 }
54 56
55 57
58 Handle<FixedDoubleArray> Factory::NewFixedDoubleArrayWithHoles(
59 int size,
60 PretenureFlag pretenure) {
61 ASSERT(0 <= size);
62 Handle<FixedDoubleArray> array = NewFixedDoubleArray(size, pretenure);
63 for (int i = 0; i < size; ++i) {
64 array->set_the_hole(i);
65 }
66 return array;
67 }
68
69
56 Handle<ConstantPoolArray> Factory::NewConstantPoolArray( 70 Handle<ConstantPoolArray> Factory::NewConstantPoolArray(
57 int number_of_int64_entries, 71 int number_of_int64_entries,
58 int number_of_code_ptr_entries, 72 int number_of_code_ptr_entries,
59 int number_of_heap_ptr_entries, 73 int number_of_heap_ptr_entries,
60 int number_of_int32_entries) { 74 int number_of_int32_entries) {
61 ASSERT(number_of_int64_entries > 0 || number_of_code_ptr_entries > 0 || 75 ASSERT(number_of_int64_entries > 0 || number_of_code_ptr_entries > 0 ||
62 number_of_heap_ptr_entries > 0 || number_of_int32_entries > 0); 76 number_of_heap_ptr_entries > 0 || number_of_int32_entries > 0);
63 CALL_HEAP_FUNCTION( 77 CALL_HEAP_FUNCTION(
64 isolate(), 78 isolate(),
65 isolate()->heap()->AllocateConstantPoolArray(number_of_int64_entries, 79 isolate()->heap()->AllocateConstantPoolArray(number_of_int64_entries,
(...skipping 1362 matching lines...) Expand 10 before | Expand all | Expand 10 after
1428 isolate()->factory()->NewJSArray(elements_kind, pretenure); 1442 isolate()->factory()->NewJSArray(elements_kind, pretenure);
1429 1443
1430 array->set_elements(*elements); 1444 array->set_elements(*elements);
1431 array->set_length(Smi::FromInt(length)); 1445 array->set_length(Smi::FromInt(length));
1432 JSObject::ValidateElements(array); 1446 JSObject::ValidateElements(array);
1433 return array; 1447 return array;
1434 } 1448 }
1435 1449
1436 1450
1437 void Factory::NewJSArrayStorage(Handle<JSArray> array, 1451 void Factory::NewJSArrayStorage(Handle<JSArray> array,
1438 int length, 1452 int length,
1439 int capacity, 1453 int capacity,
1440 ArrayStorageAllocationMode mode) { 1454 ArrayStorageAllocationMode mode) {
1441 CALL_HEAP_FUNCTION_VOID(isolate(), 1455 ASSERT(capacity >= length);
1442 isolate()->heap()->AllocateJSArrayStorage(*array, 1456
1443 length, 1457 if (capacity == 0) {
1444 capacity, 1458 array->set_length(Smi::FromInt(0));
1445 mode)); 1459 array->set_elements(*empty_fixed_array());
1460 return;
1461 }
1462
1463 Handle<FixedArrayBase> elms;
1464 ElementsKind elements_kind = array->GetElementsKind();
1465 if (IsFastDoubleElementsKind(elements_kind)) {
1466 if (mode == DONT_INITIALIZE_ARRAY_ELEMENTS) {
1467 elms = NewFixedDoubleArray(capacity);
1468 } else {
1469 ASSERT(mode == INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE);
1470 elms = NewFixedDoubleArrayWithHoles(capacity);
1471 }
1472 } else {
1473 ASSERT(IsFastSmiOrObjectElementsKind(elements_kind));
1474 if (mode == DONT_INITIALIZE_ARRAY_ELEMENTS) {
1475 elms = NewUninitializedFixedArray(capacity);
1476 } else {
1477 ASSERT(mode == INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE);
1478 elms = NewFixedArrayWithHoles(capacity);
1479 }
1480 }
1481
1482 array->set_elements(*elms);
1483 array->set_length(Smi::FromInt(length));
1446 } 1484 }
1447 1485
1448 1486
1449 Handle<JSGeneratorObject> Factory::NewJSGeneratorObject( 1487 Handle<JSGeneratorObject> Factory::NewJSGeneratorObject(
1450 Handle<JSFunction> function) { 1488 Handle<JSFunction> function) {
1451 ASSERT(function->shared()->is_generator()); 1489 ASSERT(function->shared()->is_generator());
1452 JSFunction::EnsureHasInitialMap(function); 1490 JSFunction::EnsureHasInitialMap(function);
1453 Handle<Map> map(function->initial_map()); 1491 Handle<Map> map(function->initial_map());
1454 ASSERT(map->instance_type() == JS_GENERATOR_OBJECT_TYPE); 1492 ASSERT(map->instance_type() == JS_GENERATOR_OBJECT_TYPE);
1455 CALL_HEAP_FUNCTION( 1493 CALL_HEAP_FUNCTION(
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
1968 if (String::Equals(name, infinity_string())) return infinity_value(); 2006 if (String::Equals(name, infinity_string())) return infinity_value();
1969 return Handle<Object>::null(); 2007 return Handle<Object>::null();
1970 } 2008 }
1971 2009
1972 2010
1973 Handle<Object> Factory::ToBoolean(bool value) { 2011 Handle<Object> Factory::ToBoolean(bool value) {
1974 return value ? true_value() : false_value(); 2012 return value ? true_value() : false_value();
1975 } 2013 }
1976 2014
1977 } } // namespace v8::internal 2015 } } // 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