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

Side by Side Diff: src/factory.cc

Issue 8133020: Simplify calling generated code from the runtime. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 2 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 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 613 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 Handle<JSArray> args) { 624 Handle<JSArray> args) {
625 Handle<String> make_str = LookupAsciiSymbol(maker); 625 Handle<String> make_str = LookupAsciiSymbol(maker);
626 Handle<Object> fun_obj( 626 Handle<Object> fun_obj(
627 isolate()->js_builtins_object()->GetPropertyNoExceptionThrown(*make_str)); 627 isolate()->js_builtins_object()->GetPropertyNoExceptionThrown(*make_str));
628 // If the builtins haven't been properly configured yet this error 628 // If the builtins haven't been properly configured yet this error
629 // constructor may not have been defined. Bail out. 629 // constructor may not have been defined. Bail out.
630 if (!fun_obj->IsJSFunction()) 630 if (!fun_obj->IsJSFunction())
631 return undefined_value(); 631 return undefined_value();
632 Handle<JSFunction> fun = Handle<JSFunction>::cast(fun_obj); 632 Handle<JSFunction> fun = Handle<JSFunction>::cast(fun_obj);
633 Handle<Object> type_obj = LookupAsciiSymbol(type); 633 Handle<Object> type_obj = LookupAsciiSymbol(type);
634 Object** argv[2] = { type_obj.location(), 634 Handle<Object> argv[] = { type_obj, args };
635 Handle<Object>::cast(args).location() };
636 635
637 // Invoke the JavaScript factory method. If an exception is thrown while 636 // Invoke the JavaScript factory method. If an exception is thrown while
638 // running the factory method, use the exception as the result. 637 // running the factory method, use the exception as the result.
639 bool caught_exception; 638 bool caught_exception;
640 Handle<Object> result = Execution::TryCall(fun, 639 Handle<Object> result = Execution::TryCall(fun,
641 isolate()->js_builtins_object(), 2, argv, &caught_exception); 640 isolate()->js_builtins_object(),
641 ARRAY_SIZE(argv),
642 argv,
643 &caught_exception);
642 return result; 644 return result;
643 } 645 }
644 646
645 647
646 Handle<Object> Factory::NewError(Handle<String> message) { 648 Handle<Object> Factory::NewError(Handle<String> message) {
647 return NewError("$Error", message); 649 return NewError("$Error", message);
648 } 650 }
649 651
650 652
651 Handle<Object> Factory::NewError(const char* constructor, 653 Handle<Object> Factory::NewError(const char* constructor,
652 Handle<String> message) { 654 Handle<String> message) {
653 Handle<String> constr = LookupAsciiSymbol(constructor); 655 Handle<String> constr = LookupAsciiSymbol(constructor);
654 Handle<JSFunction> fun = Handle<JSFunction>( 656 Handle<JSFunction> fun = Handle<JSFunction>(
655 JSFunction::cast(isolate()->js_builtins_object()-> 657 JSFunction::cast(isolate()->js_builtins_object()->
656 GetPropertyNoExceptionThrown(*constr))); 658 GetPropertyNoExceptionThrown(*constr)));
657 Object** argv[1] = { Handle<Object>::cast(message).location() }; 659 Handle<Object> argv[] = { message };
658 660
659 // Invoke the JavaScript factory method. If an exception is thrown while 661 // Invoke the JavaScript factory method. If an exception is thrown while
660 // running the factory method, use the exception as the result. 662 // running the factory method, use the exception as the result.
661 bool caught_exception; 663 bool caught_exception;
662 Handle<Object> result = Execution::TryCall(fun, 664 Handle<Object> result = Execution::TryCall(fun,
663 isolate()->js_builtins_object(), 1, argv, &caught_exception); 665 isolate()->js_builtins_object(),
666 ARRAY_SIZE(argv),
667 argv,
668 &caught_exception);
664 return result; 669 return result;
665 } 670 }
666 671
667 672
668 Handle<JSFunction> Factory::NewFunction(Handle<String> name, 673 Handle<JSFunction> Factory::NewFunction(Handle<String> name,
669 InstanceType type, 674 InstanceType type,
670 int instance_size, 675 int instance_size,
671 Handle<Code> code, 676 Handle<Code> code,
672 bool force_initial_map) { 677 bool force_initial_map) {
673 // Allocate the function 678 // Allocate the function
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
1325 Handle<Object> Factory::GlobalConstantFor(Handle<String> name) { 1330 Handle<Object> Factory::GlobalConstantFor(Handle<String> name) {
1326 Heap* h = isolate()->heap(); 1331 Heap* h = isolate()->heap();
1327 if (name->Equals(h->undefined_symbol())) return undefined_value(); 1332 if (name->Equals(h->undefined_symbol())) return undefined_value();
1328 if (name->Equals(h->nan_symbol())) return nan_value(); 1333 if (name->Equals(h->nan_symbol())) return nan_value();
1329 if (name->Equals(h->infinity_symbol())) return infinity_value(); 1334 if (name->Equals(h->infinity_symbol())) return infinity_value();
1330 return Handle<Object>::null(); 1335 return Handle<Object>::null();
1331 } 1336 }
1332 1337
1333 1338
1334 } } // namespace v8::internal 1339 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698