OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 | 397 |
398 Handle<JSGlobalPropertyCell> Factory::NewJSGlobalPropertyCell( | 398 Handle<JSGlobalPropertyCell> Factory::NewJSGlobalPropertyCell( |
399 Handle<Object> value) { | 399 Handle<Object> value) { |
400 CALL_HEAP_FUNCTION( | 400 CALL_HEAP_FUNCTION( |
401 isolate(), | 401 isolate(), |
402 isolate()->heap()->AllocateJSGlobalPropertyCell(*value), | 402 isolate()->heap()->AllocateJSGlobalPropertyCell(*value), |
403 JSGlobalPropertyCell); | 403 JSGlobalPropertyCell); |
404 } | 404 } |
405 | 405 |
406 | 406 |
407 Handle<Map> Factory::NewMap(InstanceType type, int instance_size) { | 407 Handle<Map> Factory::NewMap(InstanceType type, |
| 408 int instance_size, |
| 409 ElementsKind elements_kind) { |
408 CALL_HEAP_FUNCTION( | 410 CALL_HEAP_FUNCTION( |
409 isolate(), | 411 isolate(), |
410 isolate()->heap()->AllocateMap(type, instance_size), | 412 isolate()->heap()->AllocateMap(type, instance_size, elements_kind), |
411 Map); | 413 Map); |
412 } | 414 } |
413 | 415 |
414 | 416 |
415 Handle<JSObject> Factory::NewFunctionPrototype(Handle<JSFunction> function) { | 417 Handle<JSObject> Factory::NewFunctionPrototype(Handle<JSFunction> function) { |
416 CALL_HEAP_FUNCTION( | 418 CALL_HEAP_FUNCTION( |
417 isolate(), | 419 isolate(), |
418 isolate()->heap()->AllocateFunctionPrototype(*function), | 420 isolate()->heap()->AllocateFunctionPrototype(*function), |
419 JSObject); | 421 JSObject); |
420 } | 422 } |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 Handle<JSFunction> function = NewFunction(name, prototype); | 705 Handle<JSFunction> function = NewFunction(name, prototype); |
704 | 706 |
705 // Setup the code pointer in both the shared function info and in | 707 // Setup the code pointer in both the shared function info and in |
706 // the function itself. | 708 // the function itself. |
707 function->shared()->set_code(*code); | 709 function->shared()->set_code(*code); |
708 function->set_code(*code); | 710 function->set_code(*code); |
709 | 711 |
710 if (force_initial_map || | 712 if (force_initial_map || |
711 type != JS_OBJECT_TYPE || | 713 type != JS_OBJECT_TYPE || |
712 instance_size != JSObject::kHeaderSize) { | 714 instance_size != JSObject::kHeaderSize) { |
713 Handle<Map> initial_map = NewMap(type, instance_size); | 715 ElementsKind default_elements_kind = FLAG_smi_only_arrays |
| 716 ? FAST_SMI_ONLY_ELEMENTS |
| 717 : FAST_ELEMENTS; |
| 718 Handle<Map> initial_map = NewMap(type, |
| 719 instance_size, |
| 720 default_elements_kind); |
714 function->set_initial_map(*initial_map); | 721 function->set_initial_map(*initial_map); |
715 initial_map->set_constructor(*function); | 722 initial_map->set_constructor(*function); |
716 } | 723 } |
717 | 724 |
718 // Set function.prototype and give the prototype a constructor | 725 // Set function.prototype and give the prototype a constructor |
719 // property that refers to the function. | 726 // property that refers to the function. |
720 SetPrototypeProperty(function, prototype); | 727 SetPrototypeProperty(function, prototype); |
721 // Currently safe because it is only invoked from Genesis. | 728 // Currently safe because it is only invoked from Genesis. |
722 SetLocalPropertyNoThrow(prototype, constructor_symbol(), function, DONT_ENUM); | 729 SetLocalPropertyNoThrow(prototype, constructor_symbol(), function, DONT_ENUM); |
723 return function; | 730 return function; |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
889 Handle<JSArray>::cast(obj)->Initialize(capacity), | 896 Handle<JSArray>::cast(obj)->Initialize(capacity), |
890 JSArray); | 897 JSArray); |
891 } | 898 } |
892 | 899 |
893 | 900 |
894 Handle<JSArray> Factory::NewJSArrayWithElements(Handle<FixedArray> elements, | 901 Handle<JSArray> Factory::NewJSArrayWithElements(Handle<FixedArray> elements, |
895 PretenureFlag pretenure) { | 902 PretenureFlag pretenure) { |
896 Handle<JSArray> result = | 903 Handle<JSArray> result = |
897 Handle<JSArray>::cast(NewJSObject(isolate()->array_function(), | 904 Handle<JSArray>::cast(NewJSObject(isolate()->array_function(), |
898 pretenure)); | 905 pretenure)); |
899 result->SetContent(*elements); | 906 SetContent(result, elements); |
900 return result; | 907 return result; |
901 } | 908 } |
902 | 909 |
903 | 910 |
| 911 void Factory::SetContent(Handle<JSArray> array, |
| 912 Handle<FixedArray> elements) { |
| 913 CALL_HEAP_FUNCTION_VOID( |
| 914 isolate(), |
| 915 array->SetContent(*elements)); |
| 916 } |
| 917 |
| 918 |
| 919 void Factory::EnsureCanContainNonSmiElements(Handle<JSArray> array) { |
| 920 CALL_HEAP_FUNCTION_VOID( |
| 921 isolate(), |
| 922 array->EnsureCanContainNonSmiElements()); |
| 923 } |
| 924 |
| 925 |
904 Handle<JSProxy> Factory::NewJSProxy(Handle<Object> handler, | 926 Handle<JSProxy> Factory::NewJSProxy(Handle<Object> handler, |
905 Handle<Object> prototype) { | 927 Handle<Object> prototype) { |
906 CALL_HEAP_FUNCTION( | 928 CALL_HEAP_FUNCTION( |
907 isolate(), | 929 isolate(), |
908 isolate()->heap()->AllocateJSProxy(*handler, *prototype), | 930 isolate()->heap()->AllocateJSProxy(*handler, *prototype), |
909 JSProxy); | 931 JSProxy); |
910 } | 932 } |
911 | 933 |
912 | 934 |
913 void Factory::BecomeJSObject(Handle<JSReceiver> object) { | 935 void Factory::BecomeJSObject(Handle<JSReceiver> object) { |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1287 Execution::ConfigureInstance(instance, | 1309 Execution::ConfigureInstance(instance, |
1288 instance_template, | 1310 instance_template, |
1289 pending_exception); | 1311 pending_exception); |
1290 } else { | 1312 } else { |
1291 *pending_exception = false; | 1313 *pending_exception = false; |
1292 } | 1314 } |
1293 } | 1315 } |
1294 | 1316 |
1295 | 1317 |
1296 } } // namespace v8::internal | 1318 } } // namespace v8::internal |
OLD | NEW |