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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 int begin, | 227 int begin, |
228 int end) { | 228 int end) { |
229 ASSERT(begin > 0 || end < str->length()); | 229 ASSERT(begin > 0 || end < str->length()); |
230 CALL_HEAP_FUNCTION(isolate(), | 230 CALL_HEAP_FUNCTION(isolate(), |
231 isolate()->heap()->AllocateSubString(*str, begin, end), | 231 isolate()->heap()->AllocateSubString(*str, begin, end), |
232 String); | 232 String); |
233 } | 233 } |
234 | 234 |
235 | 235 |
236 Handle<String> Factory::NewExternalStringFromAscii( | 236 Handle<String> Factory::NewExternalStringFromAscii( |
237 ExternalAsciiString::Resource* resource) { | 237 const ExternalAsciiString::Resource* resource) { |
238 CALL_HEAP_FUNCTION( | 238 CALL_HEAP_FUNCTION( |
239 isolate(), | 239 isolate(), |
240 isolate()->heap()->AllocateExternalStringFromAscii(resource), | 240 isolate()->heap()->AllocateExternalStringFromAscii(resource), |
241 String); | 241 String); |
242 } | 242 } |
243 | 243 |
244 | 244 |
245 Handle<String> Factory::NewExternalStringFromTwoByte( | 245 Handle<String> Factory::NewExternalStringFromTwoByte( |
246 ExternalTwoByteString::Resource* resource) { | 246 const ExternalTwoByteString::Resource* resource) { |
247 CALL_HEAP_FUNCTION( | 247 CALL_HEAP_FUNCTION( |
248 isolate(), | 248 isolate(), |
249 isolate()->heap()->AllocateExternalStringFromTwoByte(resource), | 249 isolate()->heap()->AllocateExternalStringFromTwoByte(resource), |
250 String); | 250 String); |
251 } | 251 } |
252 | 252 |
253 | 253 |
254 Handle<Context> Factory::NewGlobalContext() { | 254 Handle<Context> Factory::NewGlobalContext() { |
255 CALL_HEAP_FUNCTION( | 255 CALL_HEAP_FUNCTION( |
256 isolate(), | 256 isolate(), |
(...skipping 140 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 27 matching lines...) Expand all Loading... |
448 copy->set_visitor_id(StaticVisitorBase::GetVisitorId(*copy)); | 450 copy->set_visitor_id(StaticVisitorBase::GetVisitorId(*copy)); |
449 return copy; | 451 return copy; |
450 } | 452 } |
451 | 453 |
452 | 454 |
453 Handle<Map> Factory::CopyMapDropTransitions(Handle<Map> src) { | 455 Handle<Map> Factory::CopyMapDropTransitions(Handle<Map> src) { |
454 CALL_HEAP_FUNCTION(isolate(), src->CopyDropTransitions(), Map); | 456 CALL_HEAP_FUNCTION(isolate(), src->CopyDropTransitions(), Map); |
455 } | 457 } |
456 | 458 |
457 | 459 |
458 Handle<Map> Factory::GetFastElementsMap(Handle<Map> src) { | |
459 CALL_HEAP_FUNCTION(isolate(), src->GetFastElementsMap(), Map); | |
460 } | |
461 | |
462 | |
463 Handle<Map> Factory::GetSlowElementsMap(Handle<Map> src) { | |
464 CALL_HEAP_FUNCTION(isolate(), src->GetSlowElementsMap(), Map); | |
465 } | |
466 | |
467 | |
468 Handle<Map> Factory::GetElementsTransitionMap( | 460 Handle<Map> Factory::GetElementsTransitionMap( |
469 Handle<Map> src, | 461 Handle<JSObject> src, |
470 ElementsKind elements_kind, | 462 ElementsKind elements_kind) { |
471 bool safe_to_add_transition) { | |
472 CALL_HEAP_FUNCTION(isolate(), | 463 CALL_HEAP_FUNCTION(isolate(), |
473 src->GetElementsTransitionMap(elements_kind, | 464 src->GetElementsTransitionMap(elements_kind), |
474 safe_to_add_transition), | |
475 Map); | 465 Map); |
476 } | 466 } |
477 | 467 |
478 | 468 |
479 Handle<FixedArray> Factory::CopyFixedArray(Handle<FixedArray> array) { | 469 Handle<FixedArray> Factory::CopyFixedArray(Handle<FixedArray> array) { |
480 CALL_HEAP_FUNCTION(isolate(), array->Copy(), FixedArray); | 470 CALL_HEAP_FUNCTION(isolate(), array->Copy(), FixedArray); |
481 } | 471 } |
482 | 472 |
483 | 473 |
484 Handle<JSFunction> Factory::BaseNewFunctionFromSharedFunctionInfo( | 474 Handle<JSFunction> Factory::BaseNewFunctionFromSharedFunctionInfo( |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
715 Handle<JSFunction> function = NewFunction(name, prototype); | 705 Handle<JSFunction> function = NewFunction(name, prototype); |
716 | 706 |
717 // 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 |
718 // the function itself. | 708 // the function itself. |
719 function->shared()->set_code(*code); | 709 function->shared()->set_code(*code); |
720 function->set_code(*code); | 710 function->set_code(*code); |
721 | 711 |
722 if (force_initial_map || | 712 if (force_initial_map || |
723 type != JS_OBJECT_TYPE || | 713 type != JS_OBJECT_TYPE || |
724 instance_size != JSObject::kHeaderSize) { | 714 instance_size != JSObject::kHeaderSize) { |
725 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); |
726 function->set_initial_map(*initial_map); | 721 function->set_initial_map(*initial_map); |
727 initial_map->set_constructor(*function); | 722 initial_map->set_constructor(*function); |
728 } | 723 } |
729 | 724 |
730 // Set function.prototype and give the prototype a constructor | 725 // Set function.prototype and give the prototype a constructor |
731 // property that refers to the function. | 726 // property that refers to the function. |
732 SetPrototypeProperty(function, prototype); | 727 SetPrototypeProperty(function, prototype); |
733 // Currently safe because it is only invoked from Genesis. | 728 // Currently safe because it is only invoked from Genesis. |
734 SetLocalPropertyNoThrow(prototype, constructor_symbol(), function, DONT_ENUM); | 729 SetLocalPropertyNoThrow(prototype, constructor_symbol(), function, DONT_ENUM); |
735 return function; | 730 return function; |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
901 Handle<JSArray>::cast(obj)->Initialize(capacity), | 896 Handle<JSArray>::cast(obj)->Initialize(capacity), |
902 JSArray); | 897 JSArray); |
903 } | 898 } |
904 | 899 |
905 | 900 |
906 Handle<JSArray> Factory::NewJSArrayWithElements(Handle<FixedArray> elements, | 901 Handle<JSArray> Factory::NewJSArrayWithElements(Handle<FixedArray> elements, |
907 PretenureFlag pretenure) { | 902 PretenureFlag pretenure) { |
908 Handle<JSArray> result = | 903 Handle<JSArray> result = |
909 Handle<JSArray>::cast(NewJSObject(isolate()->array_function(), | 904 Handle<JSArray>::cast(NewJSObject(isolate()->array_function(), |
910 pretenure)); | 905 pretenure)); |
911 result->SetContent(*elements); | 906 SetContent(result, elements); |
912 return result; | 907 return result; |
913 } | 908 } |
914 | 909 |
915 | 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 |
916 Handle<JSProxy> Factory::NewJSProxy(Handle<Object> handler, | 926 Handle<JSProxy> Factory::NewJSProxy(Handle<Object> handler, |
917 Handle<Object> prototype) { | 927 Handle<Object> prototype) { |
918 CALL_HEAP_FUNCTION( | 928 CALL_HEAP_FUNCTION( |
919 isolate(), | 929 isolate(), |
920 isolate()->heap()->AllocateJSProxy(*handler, *prototype), | 930 isolate()->heap()->AllocateJSProxy(*handler, *prototype), |
921 JSProxy); | 931 JSProxy); |
922 } | 932 } |
923 | 933 |
924 | 934 |
925 void Factory::BecomeJSObject(Handle<JSReceiver> object) { | 935 void Factory::BecomeJSObject(Handle<JSReceiver> object) { |
926 CALL_HEAP_FUNCTION_VOID( | 936 CALL_HEAP_FUNCTION_VOID( |
927 isolate(), | 937 isolate(), |
928 isolate()->heap()->ReinitializeJSReceiver( | 938 isolate()->heap()->ReinitializeJSReceiver( |
929 *object, JS_OBJECT_TYPE, JSObject::kHeaderSize)); | 939 *object, JS_OBJECT_TYPE, JSObject::kHeaderSize)); |
930 } | 940 } |
931 | 941 |
932 | 942 |
933 void Factory::BecomeJSFunction(Handle<JSReceiver> object) { | 943 void Factory::BecomeJSFunction(Handle<JSReceiver> object) { |
934 CALL_HEAP_FUNCTION_VOID( | 944 CALL_HEAP_FUNCTION_VOID( |
935 isolate(), | 945 isolate(), |
936 isolate()->heap()->ReinitializeJSReceiver( | 946 isolate()->heap()->ReinitializeJSReceiver( |
937 *object, JS_FUNCTION_TYPE, JSFunction::kSize)); | 947 *object, JS_FUNCTION_TYPE, JSFunction::kSize)); |
938 } | 948 } |
939 | 949 |
940 | 950 |
| 951 void Factory::SetIdentityHash(Handle<JSObject> object, Object* hash) { |
| 952 CALL_HEAP_FUNCTION_VOID( |
| 953 isolate(), |
| 954 object->SetIdentityHash(hash, ALLOW_CREATION)); |
| 955 } |
| 956 |
| 957 |
941 Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo( | 958 Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo( |
942 Handle<String> name, | 959 Handle<String> name, |
943 int number_of_literals, | 960 int number_of_literals, |
944 Handle<Code> code, | 961 Handle<Code> code, |
945 Handle<SerializedScopeInfo> scope_info) { | 962 Handle<SerializedScopeInfo> scope_info) { |
946 Handle<SharedFunctionInfo> shared = NewSharedFunctionInfo(name); | 963 Handle<SharedFunctionInfo> shared = NewSharedFunctionInfo(name); |
947 shared->set_code(*code); | 964 shared->set_code(*code); |
948 shared->set_scope_info(*scope_info); | 965 shared->set_scope_info(*scope_info); |
949 int literals_array_size = number_of_literals; | 966 int literals_array_size = number_of_literals; |
950 // If the function contains object, regexp or array literals, | 967 // If the function contains object, regexp or array literals, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
983 SharedFunctionInfo); | 1000 SharedFunctionInfo); |
984 } | 1001 } |
985 | 1002 |
986 | 1003 |
987 Handle<String> Factory::NumberToString(Handle<Object> number) { | 1004 Handle<String> Factory::NumberToString(Handle<Object> number) { |
988 CALL_HEAP_FUNCTION(isolate(), | 1005 CALL_HEAP_FUNCTION(isolate(), |
989 isolate()->heap()->NumberToString(*number), String); | 1006 isolate()->heap()->NumberToString(*number), String); |
990 } | 1007 } |
991 | 1008 |
992 | 1009 |
| 1010 Handle<String> Factory::Uint32ToString(uint32_t value) { |
| 1011 CALL_HEAP_FUNCTION(isolate(), |
| 1012 isolate()->heap()->Uint32ToString(value), String); |
| 1013 } |
| 1014 |
| 1015 |
993 Handle<NumberDictionary> Factory::DictionaryAtNumberPut( | 1016 Handle<NumberDictionary> Factory::DictionaryAtNumberPut( |
994 Handle<NumberDictionary> dictionary, | 1017 Handle<NumberDictionary> dictionary, |
995 uint32_t key, | 1018 uint32_t key, |
996 Handle<Object> value) { | 1019 Handle<Object> value) { |
997 CALL_HEAP_FUNCTION(isolate(), | 1020 CALL_HEAP_FUNCTION(isolate(), |
998 dictionary->AtNumberPut(key, *value), | 1021 dictionary->AtNumberPut(key, *value), |
999 NumberDictionary); | 1022 NumberDictionary); |
1000 } | 1023 } |
1001 | 1024 |
1002 | 1025 |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1292 if (!instance_template->IsUndefined()) { | 1315 if (!instance_template->IsUndefined()) { |
1293 Execution::ConfigureInstance(instance, | 1316 Execution::ConfigureInstance(instance, |
1294 instance_template, | 1317 instance_template, |
1295 pending_exception); | 1318 pending_exception); |
1296 } else { | 1319 } else { |
1297 *pending_exception = false; | 1320 *pending_exception = false; |
1298 } | 1321 } |
1299 } | 1322 } |
1300 | 1323 |
1301 | 1324 |
| 1325 Handle<Object> Factory::GlobalConstantFor(Handle<String> name) { |
| 1326 Heap* h = isolate()->heap(); |
| 1327 if (name->Equals(h->undefined_symbol())) return undefined_value(); |
| 1328 if (name->Equals(h->nan_symbol())) return nan_value(); |
| 1329 if (name->Equals(h->infinity_symbol())) return infinity_value(); |
| 1330 return Handle<Object>::null(); |
| 1331 } |
| 1332 |
| 1333 |
1302 } } // namespace v8::internal | 1334 } } // namespace v8::internal |
OLD | NEW |