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

Side by Side Diff: src/factory.cc

Issue 2866008: [Isolates] Move contents of Top into Isolate.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: ensure we're synced Created 10 years, 6 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/execution.cc ('k') | src/fast-codegen.cc » ('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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 pretenure), 294 pretenure),
295 JSFunction); 295 JSFunction);
296 } 296 }
297 297
298 298
299 Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo( 299 Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo(
300 Handle<SharedFunctionInfo> function_info, 300 Handle<SharedFunctionInfo> function_info,
301 Handle<Context> context, 301 Handle<Context> context,
302 PretenureFlag pretenure) { 302 PretenureFlag pretenure) {
303 Handle<JSFunction> result = BaseNewFunctionFromSharedFunctionInfo( 303 Handle<JSFunction> result = BaseNewFunctionFromSharedFunctionInfo(
304 function_info, Top::function_map(), pretenure); 304 function_info, Isolate::Current()->function_map(), pretenure);
305 result->set_context(*context); 305 result->set_context(*context);
306 int number_of_literals = function_info->num_literals(); 306 int number_of_literals = function_info->num_literals();
307 Handle<FixedArray> literals = 307 Handle<FixedArray> literals =
308 Factory::NewFixedArray(number_of_literals, pretenure); 308 Factory::NewFixedArray(number_of_literals, pretenure);
309 if (number_of_literals > 0) { 309 if (number_of_literals > 0) {
310 // Store the object, regexp and array functions in the literals 310 // Store the object, regexp and array functions in the literals
311 // array prefix. These functions will be used when creating 311 // array prefix. These functions will be used when creating
312 // object, regexp and array literals in this function. 312 // object, regexp and array literals in this function.
313 literals->set(JSFunction::kLiteralGlobalContextIndex, 313 literals->set(JSFunction::kLiteralGlobalContextIndex,
314 context->global_context()); 314 context->global_context());
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 Handle<Object> Factory::NewError(const char* type, 405 Handle<Object> Factory::NewError(const char* type,
406 Vector< Handle<Object> > args) { 406 Vector< Handle<Object> > args) {
407 return NewError("MakeError", type, args); 407 return NewError("MakeError", type, args);
408 } 408 }
409 409
410 410
411 Handle<Object> Factory::NewError(const char* maker, 411 Handle<Object> Factory::NewError(const char* maker,
412 const char* type, 412 const char* type,
413 Handle<JSArray> args) { 413 Handle<JSArray> args) {
414 Handle<String> make_str = Factory::LookupAsciiSymbol(maker); 414 Handle<String> make_str = Factory::LookupAsciiSymbol(maker);
415 Handle<Object> fun_obj(Top::builtins()->GetProperty(*make_str)); 415 Handle<Object> fun_obj(
416 Isolate::Current()->builtins()->GetProperty(*make_str));
416 // If the builtins haven't been properly configured yet this error 417 // If the builtins haven't been properly configured yet this error
417 // constructor may not have been defined. Bail out. 418 // constructor may not have been defined. Bail out.
418 if (!fun_obj->IsJSFunction()) 419 if (!fun_obj->IsJSFunction())
419 return Factory::undefined_value(); 420 return Factory::undefined_value();
420 Handle<JSFunction> fun = Handle<JSFunction>::cast(fun_obj); 421 Handle<JSFunction> fun = Handle<JSFunction>::cast(fun_obj);
421 Handle<Object> type_obj = Factory::LookupAsciiSymbol(type); 422 Handle<Object> type_obj = Factory::LookupAsciiSymbol(type);
422 Object** argv[2] = { type_obj.location(), 423 Object** argv[2] = { type_obj.location(),
423 Handle<Object>::cast(args).location() }; 424 Handle<Object>::cast(args).location() };
424 425
425 // Invoke the JavaScript factory method. If an exception is thrown while 426 // Invoke the JavaScript factory method. If an exception is thrown while
426 // running the factory method, use the exception as the result. 427 // running the factory method, use the exception as the result.
427 bool caught_exception; 428 bool caught_exception;
428 Handle<Object> result = Execution::TryCall(fun, 429 Handle<Object> result = Execution::TryCall(fun,
429 Top::builtins(), 430 Isolate::Current()->builtins(),
430 2, 431 2,
431 argv, 432 argv,
432 &caught_exception); 433 &caught_exception);
433 return result; 434 return result;
434 } 435 }
435 436
436 437
437 Handle<Object> Factory::NewError(Handle<String> message) { 438 Handle<Object> Factory::NewError(Handle<String> message) {
438 return NewError("$Error", message); 439 return NewError("$Error", message);
439 } 440 }
440 441
441 442
442 Handle<Object> Factory::NewError(const char* constructor, 443 Handle<Object> Factory::NewError(const char* constructor,
443 Handle<String> message) { 444 Handle<String> message) {
444 Handle<String> constr = Factory::LookupAsciiSymbol(constructor); 445 Handle<String> constr = Factory::LookupAsciiSymbol(constructor);
445 Handle<JSFunction> fun = 446 Handle<JSFunction> fun =
446 Handle<JSFunction>( 447 Handle<JSFunction>(
447 JSFunction::cast( 448 JSFunction::cast(
448 Top::builtins()->GetProperty(*constr))); 449 Isolate::Current()->builtins()->GetProperty(*constr)));
449 Object** argv[1] = { Handle<Object>::cast(message).location() }; 450 Object** argv[1] = { Handle<Object>::cast(message).location() };
450 451
451 // Invoke the JavaScript factory method. If an exception is thrown while 452 // Invoke the JavaScript factory method. If an exception is thrown while
452 // running the factory method, use the exception as the result. 453 // running the factory method, use the exception as the result.
453 bool caught_exception; 454 bool caught_exception;
454 Handle<Object> result = Execution::TryCall(fun, 455 Handle<Object> result = Execution::TryCall(fun,
455 Top::builtins(), 456 Isolate::Current()->builtins(),
456 1, 457 1,
457 argv, 458 argv,
458 &caught_exception); 459 &caught_exception);
459 return result; 460 return result;
460 } 461 }
461 462
462 463
463 Handle<JSFunction> Factory::NewFunction(Handle<String> name, 464 Handle<JSFunction> Factory::NewFunction(Handle<String> name,
464 InstanceType type, 465 InstanceType type,
465 int instance_size, 466 int instance_size,
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 642
642 643
643 Handle<JSObject> Factory::NewJSObjectFromMap(Handle<Map> map) { 644 Handle<JSObject> Factory::NewJSObjectFromMap(Handle<Map> map) {
644 CALL_HEAP_FUNCTION(HEAP->AllocateJSObjectFromMap(*map, NOT_TENURED), 645 CALL_HEAP_FUNCTION(HEAP->AllocateJSObjectFromMap(*map, NOT_TENURED),
645 JSObject); 646 JSObject);
646 } 647 }
647 648
648 649
649 Handle<JSArray> Factory::NewJSArray(int length, 650 Handle<JSArray> Factory::NewJSArray(int length,
650 PretenureFlag pretenure) { 651 PretenureFlag pretenure) {
651 Handle<JSObject> obj = NewJSObject(Top::array_function(), pretenure); 652 Handle<JSObject> obj =
653 NewJSObject(Isolate::Current()->array_function(), pretenure);
652 CALL_HEAP_FUNCTION(Handle<JSArray>::cast(obj)->Initialize(length), JSArray); 654 CALL_HEAP_FUNCTION(Handle<JSArray>::cast(obj)->Initialize(length), JSArray);
653 } 655 }
654 656
655 657
656 Handle<JSArray> Factory::NewJSArrayWithElements(Handle<FixedArray> elements, 658 Handle<JSArray> Factory::NewJSArrayWithElements(Handle<FixedArray> elements,
657 PretenureFlag pretenure) { 659 PretenureFlag pretenure) {
658 Handle<JSArray> result = 660 Handle<JSArray> result =
659 Handle<JSArray>::cast(NewJSObject(Top::array_function(), pretenure)); 661 Handle<JSArray>::cast(NewJSObject(Isolate::Current()->array_function(),
662 pretenure));
660 result->SetContent(*elements); 663 result->SetContent(*elements);
661 return result; 664 return result;
662 } 665 }
663 666
664 667
665 Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo( 668 Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo(
666 Handle<String> name, int number_of_literals, Handle<Code> code) { 669 Handle<String> name, int number_of_literals, Handle<Code> code) {
667 Handle<SharedFunctionInfo> shared = NewSharedFunctionInfo(name); 670 Handle<SharedFunctionInfo> shared = NewSharedFunctionInfo(name);
668 shared->set_code(*code); 671 shared->set_code(*code);
669 int literals_array_size = number_of_literals; 672 int literals_array_size = number_of_literals;
(...skipping 23 matching lines...) Expand all
693 Handle<NumberDictionary> dictionary, 696 Handle<NumberDictionary> dictionary,
694 uint32_t key, 697 uint32_t key,
695 Handle<Object> value) { 698 Handle<Object> value) {
696 CALL_HEAP_FUNCTION(dictionary->AtNumberPut(key, *value), NumberDictionary); 699 CALL_HEAP_FUNCTION(dictionary->AtNumberPut(key, *value), NumberDictionary);
697 } 700 }
698 701
699 702
700 Handle<JSFunction> Factory::NewFunctionHelper(Handle<String> name, 703 Handle<JSFunction> Factory::NewFunctionHelper(Handle<String> name,
701 Handle<Object> prototype) { 704 Handle<Object> prototype) {
702 Handle<SharedFunctionInfo> function_share = NewSharedFunctionInfo(name); 705 Handle<SharedFunctionInfo> function_share = NewSharedFunctionInfo(name);
703 CALL_HEAP_FUNCTION(HEAP->AllocateFunction(*Top::function_map(), 706 CALL_HEAP_FUNCTION(HEAP->AllocateFunction(*Isolate::Current()->function_map(),
704 *function_share, 707 *function_share,
705 *prototype), 708 *prototype),
706 JSFunction); 709 JSFunction);
707 } 710 }
708 711
709 712
710 Handle<JSFunction> Factory::NewFunction(Handle<String> name, 713 Handle<JSFunction> Factory::NewFunction(Handle<String> name,
711 Handle<Object> prototype) { 714 Handle<Object> prototype) {
712 Handle<JSFunction> fun = NewFunctionHelper(name, prototype); 715 Handle<JSFunction> fun = NewFunctionHelper(name, prototype);
713 fun->set_context(Top::context()->global_context()); 716 fun->set_context(Isolate::Current()->context()->global_context());
714 return fun; 717 return fun;
715 } 718 }
716 719
717 720
718 Handle<JSFunction> Factory::NewFunctionWithoutPrototypeHelper( 721 Handle<JSFunction> Factory::NewFunctionWithoutPrototypeHelper(
719 Handle<String> name) { 722 Handle<String> name) {
720 Handle<SharedFunctionInfo> function_share = NewSharedFunctionInfo(name); 723 Handle<SharedFunctionInfo> function_share = NewSharedFunctionInfo(name);
721 CALL_HEAP_FUNCTION(HEAP->AllocateFunction( 724 CALL_HEAP_FUNCTION(HEAP->AllocateFunction(
722 *Top::function_without_prototype_map(), 725 *Isolate::Current()->function_without_prototype_map(),
723 *function_share, 726 *function_share,
724 *the_hole_value()), 727 *the_hole_value()),
725 JSFunction); 728 JSFunction);
726 } 729 }
727 730
728 731
729 Handle<JSFunction> Factory::NewFunctionWithoutPrototype(Handle<String> name) { 732 Handle<JSFunction> Factory::NewFunctionWithoutPrototype(Handle<String> name) {
730 Handle<JSFunction> fun = NewFunctionWithoutPrototypeHelper(name); 733 Handle<JSFunction> fun = NewFunctionWithoutPrototypeHelper(name);
731 fun->set_context(Top::context()->global_context()); 734 fun->set_context(Isolate::Current()->context()->global_context());
732 return fun; 735 return fun;
733 } 736 }
734 737
735 738
736 Handle<Object> Factory::ToObject(Handle<Object> object) { 739 Handle<Object> Factory::ToObject(Handle<Object> object) {
737 CALL_HEAP_FUNCTION(object->ToObject(), Object); 740 CALL_HEAP_FUNCTION(object->ToObject(), Object);
738 } 741 }
739 742
740 743
741 Handle<Object> Factory::ToObject(Handle<Object> object, 744 Handle<Object> Factory::ToObject(Handle<Object> object,
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
972 Execution::ConfigureInstance(instance, 975 Execution::ConfigureInstance(instance,
973 instance_template, 976 instance_template,
974 pending_exception); 977 pending_exception);
975 } else { 978 } else {
976 *pending_exception = false; 979 *pending_exception = false;
977 } 980 }
978 } 981 }
979 982
980 983
981 } } // namespace v8::internal 984 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/execution.cc ('k') | src/fast-codegen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698