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

Side by Side Diff: src/factory.cc

Issue 6711027: [Isolates] Merge 7201:7258 from bleeding_edge to isolates. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: Created 9 years, 9 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
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 pretenure), 414 pretenure),
415 JSFunction); 415 JSFunction);
416 } 416 }
417 417
418 418
419 Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo( 419 Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo(
420 Handle<SharedFunctionInfo> function_info, 420 Handle<SharedFunctionInfo> function_info,
421 Handle<Context> context, 421 Handle<Context> context,
422 PretenureFlag pretenure) { 422 PretenureFlag pretenure) {
423 Handle<JSFunction> result = BaseNewFunctionFromSharedFunctionInfo( 423 Handle<JSFunction> result = BaseNewFunctionFromSharedFunctionInfo(
424 function_info, isolate()->function_map(), pretenure); 424 function_info,
425 function_info->strict_mode()
426 ? isolate()->strict_mode_function_map()
427 : isolate()->function_map(),
428 pretenure);
429
425 result->set_context(*context); 430 result->set_context(*context);
426 int number_of_literals = function_info->num_literals(); 431 int number_of_literals = function_info->num_literals();
427 Handle<FixedArray> literals = NewFixedArray(number_of_literals, pretenure); 432 Handle<FixedArray> literals = NewFixedArray(number_of_literals, pretenure);
428 if (number_of_literals > 0) { 433 if (number_of_literals > 0) {
429 // Store the object, regexp and array functions in the literals 434 // Store the object, regexp and array functions in the literals
430 // array prefix. These functions will be used when creating 435 // array prefix. These functions will be used when creating
431 // object, regexp and array literals in this function. 436 // object, regexp and array literals in this function.
432 literals->set(JSFunction::kLiteralGlobalContextIndex, 437 literals->set(JSFunction::kLiteralGlobalContextIndex,
433 context->global_context()); 438 context->global_context());
434 } 439 }
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 // property that refers to the function. 652 // property that refers to the function.
648 SetPrototypeProperty(function, prototype); 653 SetPrototypeProperty(function, prototype);
649 // Currently safe because it is only invoked from Genesis. 654 // Currently safe because it is only invoked from Genesis.
650 SetLocalPropertyNoThrow(prototype, constructor_symbol(), function, DONT_ENUM); 655 SetLocalPropertyNoThrow(prototype, constructor_symbol(), function, DONT_ENUM);
651 return function; 656 return function;
652 } 657 }
653 658
654 659
655 Handle<JSFunction> Factory::NewFunctionWithoutPrototype(Handle<String> name, 660 Handle<JSFunction> Factory::NewFunctionWithoutPrototype(Handle<String> name,
656 Handle<Code> code) { 661 Handle<Code> code) {
657 Handle<JSFunction> function = NewFunctionWithoutPrototype(name); 662 Handle<JSFunction> function = NewFunctionWithoutPrototype(name,
663 kNonStrictMode);
658 function->shared()->set_code(*code); 664 function->shared()->set_code(*code);
659 function->set_code(*code); 665 function->set_code(*code);
660 ASSERT(!function->has_initial_map()); 666 ASSERT(!function->has_initial_map());
661 ASSERT(!function->has_prototype()); 667 ASSERT(!function->has_prototype());
662 return function; 668 return function;
663 } 669 }
664 670
665 671
666 Handle<Code> Factory::NewCode(const CodeDesc& desc, 672 Handle<Code> Factory::NewCode(const CodeDesc& desc,
667 Code::Flags flags, 673 Code::Flags flags,
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 800
795 801
796 Handle<JSObject> Factory::NewJSObjectFromMap(Handle<Map> map) { 802 Handle<JSObject> Factory::NewJSObjectFromMap(Handle<Map> map) {
797 CALL_HEAP_FUNCTION( 803 CALL_HEAP_FUNCTION(
798 isolate(), 804 isolate(),
799 isolate()->heap()->AllocateJSObjectFromMap(*map, NOT_TENURED), 805 isolate()->heap()->AllocateJSObjectFromMap(*map, NOT_TENURED),
800 JSObject); 806 JSObject);
801 } 807 }
802 808
803 809
804 Handle<JSArray> Factory::NewJSArray(int length, 810 Handle<JSArray> Factory::NewJSArray(int capacity,
805 PretenureFlag pretenure) { 811 PretenureFlag pretenure) {
806 Handle<JSObject> obj = 812 Handle<JSObject> obj = NewJSObject(isolate()->array_function(), pretenure);
807 NewJSObject(isolate()->array_function(), pretenure);
808 CALL_HEAP_FUNCTION(isolate(), 813 CALL_HEAP_FUNCTION(isolate(),
809 Handle<JSArray>::cast(obj)->Initialize(length), 814 Handle<JSArray>::cast(obj)->Initialize(capacity),
810 JSArray); 815 JSArray);
811 } 816 }
812 817
813 818
814 Handle<JSArray> Factory::NewJSArrayWithElements(Handle<FixedArray> elements, 819 Handle<JSArray> Factory::NewJSArrayWithElements(Handle<FixedArray> elements,
815 PretenureFlag pretenure) { 820 PretenureFlag pretenure) {
816 Handle<JSArray> result = 821 Handle<JSArray> result =
817 Handle<JSArray>::cast(NewJSObject(isolate()->array_function(), 822 Handle<JSArray>::cast(NewJSObject(isolate()->array_function(),
818 pretenure)); 823 pretenure));
819 result->SetContent(*elements); 824 result->SetContent(*elements);
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 902
898 Handle<JSFunction> Factory::NewFunction(Handle<String> name, 903 Handle<JSFunction> Factory::NewFunction(Handle<String> name,
899 Handle<Object> prototype) { 904 Handle<Object> prototype) {
900 Handle<JSFunction> fun = NewFunctionHelper(name, prototype); 905 Handle<JSFunction> fun = NewFunctionHelper(name, prototype);
901 fun->set_context(isolate()->context()->global_context()); 906 fun->set_context(isolate()->context()->global_context());
902 return fun; 907 return fun;
903 } 908 }
904 909
905 910
906 Handle<JSFunction> Factory::NewFunctionWithoutPrototypeHelper( 911 Handle<JSFunction> Factory::NewFunctionWithoutPrototypeHelper(
907 Handle<String> name) { 912 Handle<String> name,
913 StrictModeFlag strict_mode) {
908 Handle<SharedFunctionInfo> function_share = NewSharedFunctionInfo(name); 914 Handle<SharedFunctionInfo> function_share = NewSharedFunctionInfo(name);
915 Handle<Map> map = strict_mode == kStrictMode
916 ? isolate()->strict_mode_function_without_prototype_map()
917 : isolate()->function_without_prototype_map();
909 CALL_HEAP_FUNCTION(isolate(), 918 CALL_HEAP_FUNCTION(isolate(),
910 isolate()->heap()->AllocateFunction( 919 isolate()->heap()->AllocateFunction(
911 *isolate()->function_without_prototype_map(), 920 *map,
912 *function_share, 921 *function_share,
913 *the_hole_value()), 922 *the_hole_value()),
914 JSFunction); 923 JSFunction);
915 } 924 }
916 925
917 926
918 Handle<JSFunction> Factory::NewFunctionWithoutPrototype(Handle<String> name) { 927 Handle<JSFunction> Factory::NewFunctionWithoutPrototype(
919 Handle<JSFunction> fun = NewFunctionWithoutPrototypeHelper(name); 928 Handle<String> name,
929 StrictModeFlag strict_mode) {
930 Handle<JSFunction> fun = NewFunctionWithoutPrototypeHelper(name, strict_mode);
920 fun->set_context(isolate()->context()->global_context()); 931 fun->set_context(isolate()->context()->global_context());
921 return fun; 932 return fun;
922 } 933 }
923 934
924 935
925 Handle<Object> Factory::ToObject(Handle<Object> object) { 936 Handle<Object> Factory::ToObject(Handle<Object> object) {
926 CALL_HEAP_FUNCTION(isolate(), object->ToObject(), Object); 937 CALL_HEAP_FUNCTION(isolate(), object->ToObject(), Object);
927 } 938 }
928 939
929 940
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
1171 Execution::ConfigureInstance(instance, 1182 Execution::ConfigureInstance(instance,
1172 instance_template, 1183 instance_template,
1173 pending_exception); 1184 pending_exception);
1174 } else { 1185 } else {
1175 *pending_exception = false; 1186 *pending_exception = false;
1176 } 1187 }
1177 } 1188 }
1178 1189
1179 1190
1180 } } // namespace v8::internal 1191 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/factory.h ('k') | src/global-handles.h » ('j') | src/global-handles.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698