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 "isolate-inl.h" | 7 #include "isolate-inl.h" |
8 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
(...skipping 1352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1363 isolate()->heap()->AllocateJSObjectFromMap( | 1363 isolate()->heap()->AllocateJSObjectFromMap( |
1364 *map, | 1364 *map, |
1365 pretenure, | 1365 pretenure, |
1366 alloc_props, | 1366 alloc_props, |
1367 allocation_site.is_null() ? NULL : *allocation_site), | 1367 allocation_site.is_null() ? NULL : *allocation_site), |
1368 JSObject); | 1368 JSObject); |
1369 } | 1369 } |
1370 | 1370 |
1371 | 1371 |
1372 Handle<JSArray> Factory::NewJSArray(ElementsKind elements_kind, | 1372 Handle<JSArray> Factory::NewJSArray(ElementsKind elements_kind, |
| 1373 PretenureFlag pretenure) { |
| 1374 CALL_HEAP_FUNCTION(isolate(), |
| 1375 isolate()->heap()->AllocateJSArray(elements_kind, |
| 1376 pretenure), |
| 1377 JSArray); |
| 1378 } |
| 1379 |
| 1380 |
| 1381 Handle<JSArray> Factory::NewJSArray(ElementsKind elements_kind, |
1373 int length, | 1382 int length, |
1374 int capacity, | 1383 int capacity, |
1375 ArrayStorageAllocationMode mode, | 1384 ArrayStorageAllocationMode mode, |
1376 PretenureFlag pretenure) { | 1385 PretenureFlag pretenure) { |
1377 CALL_HEAP_FUNCTION(isolate(), | 1386 CALL_HEAP_FUNCTION(isolate(), |
1378 isolate()->heap()->AllocateJSArrayAndStorage( | 1387 isolate()->heap()->AllocateJSArrayAndStorage( |
1379 elements_kind, | 1388 elements_kind, |
1380 length, | 1389 length, |
1381 capacity, | 1390 capacity, |
1382 mode, | 1391 mode, |
1383 pretenure), | 1392 pretenure), |
1384 JSArray); | 1393 JSArray); |
1385 } | 1394 } |
1386 | 1395 |
1387 | 1396 |
1388 Handle<JSArray> Factory::NewJSArrayWithElements(Handle<FixedArrayBase> elements, | 1397 Handle<JSArray> Factory::NewJSArrayWithElements(Handle<FixedArrayBase> elements, |
1389 ElementsKind elements_kind, | 1398 ElementsKind elements_kind, |
1390 int length, | 1399 int length, |
1391 PretenureFlag pretenure) { | 1400 PretenureFlag pretenure) { |
1392 ASSERT(length <= elements->length()); | 1401 ASSERT(length <= elements->length()); |
1393 CALL_HEAP_FUNCTION( | 1402 Handle<JSArray> array = |
1394 isolate(), | 1403 isolate()->factory()->NewJSArray(elements_kind, pretenure); |
1395 isolate()->heap()->AllocateJSArrayWithElements(*elements, | 1404 |
1396 elements_kind, | 1405 array->set_elements(*elements); |
1397 length, | 1406 array->set_length(Smi::FromInt(length)); |
1398 pretenure), | 1407 JSObject::ValidateElements(array); |
1399 JSArray); | 1408 return array; |
1400 } | 1409 } |
1401 | 1410 |
1402 | 1411 |
1403 void Factory::NewJSArrayStorage(Handle<JSArray> array, | 1412 void Factory::NewJSArrayStorage(Handle<JSArray> array, |
1404 int length, | 1413 int length, |
1405 int capacity, | 1414 int capacity, |
1406 ArrayStorageAllocationMode mode) { | 1415 ArrayStorageAllocationMode mode) { |
1407 CALL_HEAP_FUNCTION_VOID(isolate(), | 1416 CALL_HEAP_FUNCTION_VOID(isolate(), |
1408 isolate()->heap()->AllocateJSArrayStorage(*array, | 1417 isolate()->heap()->AllocateJSArrayStorage(*array, |
1409 length, | 1418 length, |
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1948 if (name->Equals(h->infinity_string())) return infinity_value(); | 1957 if (name->Equals(h->infinity_string())) return infinity_value(); |
1949 return Handle<Object>::null(); | 1958 return Handle<Object>::null(); |
1950 } | 1959 } |
1951 | 1960 |
1952 | 1961 |
1953 Handle<Object> Factory::ToBoolean(bool value) { | 1962 Handle<Object> Factory::ToBoolean(bool value) { |
1954 return value ? true_value() : false_value(); | 1963 return value ? true_value() : false_value(); |
1955 } | 1964 } |
1956 | 1965 |
1957 } } // namespace v8::internal | 1966 } } // namespace v8::internal |
OLD | NEW |