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

Side by Side Diff: src/execution.cc

Issue 895053002: Move the contents of api-natives.js to c++ (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « src/execution.h ('k') | src/factory.h » ('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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/execution.h" 5 #include "src/execution.h"
6 6
7 #include "src/bootstrapper.h" 7 #include "src/bootstrapper.h"
8 #include "src/codegen.h" 8 #include "src/codegen.h"
9 #include "src/deoptimizer.h" 9 #include "src/deoptimizer.h"
10 #include "src/isolate-inl.h" 10 #include "src/isolate-inl.h"
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 if (!TryCall(Handle<JSFunction>::cast(char_at), 623 if (!TryCall(Handle<JSFunction>::cast(char_at),
624 string, 624 string,
625 arraysize(index_arg), 625 arraysize(index_arg),
626 index_arg).ToHandle(&result)) { 626 index_arg).ToHandle(&result)) {
627 return factory->undefined_value(); 627 return factory->undefined_value();
628 } 628 }
629 return result; 629 return result;
630 } 630 }
631 631
632 632
633 MaybeHandle<JSFunction> Execution::InstantiateFunction(
634 Handle<FunctionTemplateInfo> data) {
635 Isolate* isolate = data->GetIsolate();
636 if (!data->do_not_cache()) {
637 // Fast case: see if the function has already been instantiated
638 int serial_number = Smi::cast(data->serial_number())->value();
639 Handle<JSObject> cache(isolate->native_context()->function_cache());
640 Handle<Object> elm =
641 Object::GetElement(isolate, cache, serial_number).ToHandleChecked();
642 if (elm->IsJSFunction()) return Handle<JSFunction>::cast(elm);
643 }
644 // The function has not yet been instantiated in this context; do it.
645 Handle<Object> args[] = { data };
646 Handle<Object> result;
647 ASSIGN_RETURN_ON_EXCEPTION(
648 isolate, result,
649 Call(isolate,
650 isolate->instantiate_fun(),
651 isolate->js_builtins_object(),
652 arraysize(args),
653 args),
654 JSFunction);
655 return Handle<JSFunction>::cast(result);
656 }
657
658
659 MaybeHandle<JSObject> Execution::InstantiateObject(
660 Handle<ObjectTemplateInfo> data) {
661 Isolate* isolate = data->GetIsolate();
662 Handle<Object> result;
663 if (data->property_list()->IsUndefined() &&
664 !data->constructor()->IsUndefined()) {
665 Handle<FunctionTemplateInfo> cons_template =
666 Handle<FunctionTemplateInfo>(
667 FunctionTemplateInfo::cast(data->constructor()));
668 Handle<JSFunction> cons;
669 ASSIGN_RETURN_ON_EXCEPTION(
670 isolate, cons, InstantiateFunction(cons_template), JSObject);
671 ASSIGN_RETURN_ON_EXCEPTION(isolate, result, New(cons, 0, NULL), JSObject);
672 } else {
673 Handle<Object> args[] = { data };
674 ASSIGN_RETURN_ON_EXCEPTION(
675 isolate, result,
676 Call(isolate,
677 isolate->instantiate_fun(),
678 isolate->js_builtins_object(),
679 arraysize(args),
680 args),
681 JSObject);
682 }
683 return Handle<JSObject>::cast(result);
684 }
685
686
687 MaybeHandle<Object> Execution::ConfigureInstance(
688 Isolate* isolate,
689 Handle<Object> instance,
690 Handle<Object> instance_template) {
691 Handle<Object> args[] = { instance, instance_template };
692 return Execution::Call(isolate,
693 isolate->configure_instance_fun(),
694 isolate->js_builtins_object(),
695 arraysize(args),
696 args);
697 }
698
699
700 Handle<String> Execution::GetStackTraceLine(Handle<Object> recv, 633 Handle<String> Execution::GetStackTraceLine(Handle<Object> recv,
701 Handle<JSFunction> fun, 634 Handle<JSFunction> fun,
702 Handle<Object> pos, 635 Handle<Object> pos,
703 Handle<Object> is_global) { 636 Handle<Object> is_global) {
704 Isolate* isolate = fun->GetIsolate(); 637 Isolate* isolate = fun->GetIsolate();
705 Handle<Object> args[] = { recv, fun, pos, is_global }; 638 Handle<Object> args[] = { recv, fun, pos, is_global };
706 MaybeHandle<Object> maybe_result = 639 MaybeHandle<Object> maybe_result =
707 TryCall(isolate->get_stack_trace_line_fun(), 640 TryCall(isolate->get_stack_trace_line_fun(),
708 isolate->js_builtins_object(), 641 isolate->js_builtins_object(),
709 arraysize(args), 642 arraysize(args),
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 } 678 }
746 679
747 isolate_->counters()->stack_interrupts()->Increment(); 680 isolate_->counters()->stack_interrupts()->Increment();
748 isolate_->counters()->runtime_profiler_ticks()->Increment(); 681 isolate_->counters()->runtime_profiler_ticks()->Increment();
749 isolate_->runtime_profiler()->OptimizeNow(); 682 isolate_->runtime_profiler()->OptimizeNow();
750 683
751 return isolate_->heap()->undefined_value(); 684 return isolate_->heap()->undefined_value();
752 } 685 }
753 686
754 } } // namespace v8::internal 687 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/execution.h ('k') | src/factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698