| OLD | NEW |
| 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 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 | 477 |
| 478 | 478 |
| 479 // --- C a l l s t o n a t i v e s --- | 479 // --- C a l l s t o n a t i v e s --- |
| 480 | 480 |
| 481 #define RETURN_NATIVE_CALL(name, args) \ | 481 #define RETURN_NATIVE_CALL(name, args) \ |
| 482 do { \ | 482 do { \ |
| 483 Handle<Object> argv[] = args; \ | 483 Handle<Object> argv[] = args; \ |
| 484 return Call(isolate, \ | 484 return Call(isolate, \ |
| 485 isolate->name##_fun(), \ | 485 isolate->name##_fun(), \ |
| 486 isolate->js_builtins_object(), \ | 486 isolate->js_builtins_object(), \ |
| 487 ARRAY_SIZE(argv), argv); \ | 487 arraysize(argv), argv); \ |
| 488 } while (false) | 488 } while (false) |
| 489 | 489 |
| 490 | 490 |
| 491 MaybeHandle<Object> Execution::ToNumber( | 491 MaybeHandle<Object> Execution::ToNumber( |
| 492 Isolate* isolate, Handle<Object> obj) { | 492 Isolate* isolate, Handle<Object> obj) { |
| 493 RETURN_NATIVE_CALL(to_number, { obj }); | 493 RETURN_NATIVE_CALL(to_number, { obj }); |
| 494 } | 494 } |
| 495 | 495 |
| 496 | 496 |
| 497 MaybeHandle<Object> Execution::ToString( | 497 MaybeHandle<Object> Execution::ToString( |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 factory->char_at_string()).ToHandleChecked(); | 568 factory->char_at_string()).ToHandleChecked(); |
| 569 if (!char_at->IsJSFunction()) { | 569 if (!char_at->IsJSFunction()) { |
| 570 return factory->undefined_value(); | 570 return factory->undefined_value(); |
| 571 } | 571 } |
| 572 | 572 |
| 573 Handle<Object> index_object = factory->NewNumberFromInt(int_index); | 573 Handle<Object> index_object = factory->NewNumberFromInt(int_index); |
| 574 Handle<Object> index_arg[] = { index_object }; | 574 Handle<Object> index_arg[] = { index_object }; |
| 575 Handle<Object> result; | 575 Handle<Object> result; |
| 576 if (!TryCall(Handle<JSFunction>::cast(char_at), | 576 if (!TryCall(Handle<JSFunction>::cast(char_at), |
| 577 string, | 577 string, |
| 578 ARRAY_SIZE(index_arg), | 578 arraysize(index_arg), |
| 579 index_arg).ToHandle(&result)) { | 579 index_arg).ToHandle(&result)) { |
| 580 return factory->undefined_value(); | 580 return factory->undefined_value(); |
| 581 } | 581 } |
| 582 return result; | 582 return result; |
| 583 } | 583 } |
| 584 | 584 |
| 585 | 585 |
| 586 MaybeHandle<JSFunction> Execution::InstantiateFunction( | 586 MaybeHandle<JSFunction> Execution::InstantiateFunction( |
| 587 Handle<FunctionTemplateInfo> data) { | 587 Handle<FunctionTemplateInfo> data) { |
| 588 Isolate* isolate = data->GetIsolate(); | 588 Isolate* isolate = data->GetIsolate(); |
| 589 if (!data->do_not_cache()) { | 589 if (!data->do_not_cache()) { |
| 590 // Fast case: see if the function has already been instantiated | 590 // Fast case: see if the function has already been instantiated |
| 591 int serial_number = Smi::cast(data->serial_number())->value(); | 591 int serial_number = Smi::cast(data->serial_number())->value(); |
| 592 Handle<JSObject> cache(isolate->native_context()->function_cache()); | 592 Handle<JSObject> cache(isolate->native_context()->function_cache()); |
| 593 Handle<Object> elm = | 593 Handle<Object> elm = |
| 594 Object::GetElement(isolate, cache, serial_number).ToHandleChecked(); | 594 Object::GetElement(isolate, cache, serial_number).ToHandleChecked(); |
| 595 if (elm->IsJSFunction()) return Handle<JSFunction>::cast(elm); | 595 if (elm->IsJSFunction()) return Handle<JSFunction>::cast(elm); |
| 596 } | 596 } |
| 597 // The function has not yet been instantiated in this context; do it. | 597 // The function has not yet been instantiated in this context; do it. |
| 598 Handle<Object> args[] = { data }; | 598 Handle<Object> args[] = { data }; |
| 599 Handle<Object> result; | 599 Handle<Object> result; |
| 600 ASSIGN_RETURN_ON_EXCEPTION( | 600 ASSIGN_RETURN_ON_EXCEPTION( |
| 601 isolate, result, | 601 isolate, result, |
| 602 Call(isolate, | 602 Call(isolate, |
| 603 isolate->instantiate_fun(), | 603 isolate->instantiate_fun(), |
| 604 isolate->js_builtins_object(), | 604 isolate->js_builtins_object(), |
| 605 ARRAY_SIZE(args), | 605 arraysize(args), |
| 606 args), | 606 args), |
| 607 JSFunction); | 607 JSFunction); |
| 608 return Handle<JSFunction>::cast(result); | 608 return Handle<JSFunction>::cast(result); |
| 609 } | 609 } |
| 610 | 610 |
| 611 | 611 |
| 612 MaybeHandle<JSObject> Execution::InstantiateObject( | 612 MaybeHandle<JSObject> Execution::InstantiateObject( |
| 613 Handle<ObjectTemplateInfo> data) { | 613 Handle<ObjectTemplateInfo> data) { |
| 614 Isolate* isolate = data->GetIsolate(); | 614 Isolate* isolate = data->GetIsolate(); |
| 615 Handle<Object> result; | 615 Handle<Object> result; |
| 616 if (data->property_list()->IsUndefined() && | 616 if (data->property_list()->IsUndefined() && |
| 617 !data->constructor()->IsUndefined()) { | 617 !data->constructor()->IsUndefined()) { |
| 618 Handle<FunctionTemplateInfo> cons_template = | 618 Handle<FunctionTemplateInfo> cons_template = |
| 619 Handle<FunctionTemplateInfo>( | 619 Handle<FunctionTemplateInfo>( |
| 620 FunctionTemplateInfo::cast(data->constructor())); | 620 FunctionTemplateInfo::cast(data->constructor())); |
| 621 Handle<JSFunction> cons; | 621 Handle<JSFunction> cons; |
| 622 ASSIGN_RETURN_ON_EXCEPTION( | 622 ASSIGN_RETURN_ON_EXCEPTION( |
| 623 isolate, cons, InstantiateFunction(cons_template), JSObject); | 623 isolate, cons, InstantiateFunction(cons_template), JSObject); |
| 624 ASSIGN_RETURN_ON_EXCEPTION(isolate, result, New(cons, 0, NULL), JSObject); | 624 ASSIGN_RETURN_ON_EXCEPTION(isolate, result, New(cons, 0, NULL), JSObject); |
| 625 } else { | 625 } else { |
| 626 Handle<Object> args[] = { data }; | 626 Handle<Object> args[] = { data }; |
| 627 ASSIGN_RETURN_ON_EXCEPTION( | 627 ASSIGN_RETURN_ON_EXCEPTION( |
| 628 isolate, result, | 628 isolate, result, |
| 629 Call(isolate, | 629 Call(isolate, |
| 630 isolate->instantiate_fun(), | 630 isolate->instantiate_fun(), |
| 631 isolate->js_builtins_object(), | 631 isolate->js_builtins_object(), |
| 632 ARRAY_SIZE(args), | 632 arraysize(args), |
| 633 args), | 633 args), |
| 634 JSObject); | 634 JSObject); |
| 635 } | 635 } |
| 636 return Handle<JSObject>::cast(result); | 636 return Handle<JSObject>::cast(result); |
| 637 } | 637 } |
| 638 | 638 |
| 639 | 639 |
| 640 MaybeHandle<Object> Execution::ConfigureInstance( | 640 MaybeHandle<Object> Execution::ConfigureInstance( |
| 641 Isolate* isolate, | 641 Isolate* isolate, |
| 642 Handle<Object> instance, | 642 Handle<Object> instance, |
| 643 Handle<Object> instance_template) { | 643 Handle<Object> instance_template) { |
| 644 Handle<Object> args[] = { instance, instance_template }; | 644 Handle<Object> args[] = { instance, instance_template }; |
| 645 return Execution::Call(isolate, | 645 return Execution::Call(isolate, |
| 646 isolate->configure_instance_fun(), | 646 isolate->configure_instance_fun(), |
| 647 isolate->js_builtins_object(), | 647 isolate->js_builtins_object(), |
| 648 ARRAY_SIZE(args), | 648 arraysize(args), |
| 649 args); | 649 args); |
| 650 } | 650 } |
| 651 | 651 |
| 652 | 652 |
| 653 Handle<String> Execution::GetStackTraceLine(Handle<Object> recv, | 653 Handle<String> Execution::GetStackTraceLine(Handle<Object> recv, |
| 654 Handle<JSFunction> fun, | 654 Handle<JSFunction> fun, |
| 655 Handle<Object> pos, | 655 Handle<Object> pos, |
| 656 Handle<Object> is_global) { | 656 Handle<Object> is_global) { |
| 657 Isolate* isolate = fun->GetIsolate(); | 657 Isolate* isolate = fun->GetIsolate(); |
| 658 Handle<Object> args[] = { recv, fun, pos, is_global }; | 658 Handle<Object> args[] = { recv, fun, pos, is_global }; |
| 659 MaybeHandle<Object> maybe_result = | 659 MaybeHandle<Object> maybe_result = |
| 660 TryCall(isolate->get_stack_trace_line_fun(), | 660 TryCall(isolate->get_stack_trace_line_fun(), |
| 661 isolate->js_builtins_object(), | 661 isolate->js_builtins_object(), |
| 662 ARRAY_SIZE(args), | 662 arraysize(args), |
| 663 args); | 663 args); |
| 664 Handle<Object> result; | 664 Handle<Object> result; |
| 665 if (!maybe_result.ToHandle(&result) || !result->IsString()) { | 665 if (!maybe_result.ToHandle(&result) || !result->IsString()) { |
| 666 return isolate->factory()->empty_string(); | 666 return isolate->factory()->empty_string(); |
| 667 } | 667 } |
| 668 | 668 |
| 669 return Handle<String>::cast(result); | 669 return Handle<String>::cast(result); |
| 670 } | 670 } |
| 671 | 671 |
| 672 | 672 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 698 } | 698 } |
| 699 | 699 |
| 700 isolate_->counters()->stack_interrupts()->Increment(); | 700 isolate_->counters()->stack_interrupts()->Increment(); |
| 701 isolate_->counters()->runtime_profiler_ticks()->Increment(); | 701 isolate_->counters()->runtime_profiler_ticks()->Increment(); |
| 702 isolate_->runtime_profiler()->OptimizeNow(); | 702 isolate_->runtime_profiler()->OptimizeNow(); |
| 703 | 703 |
| 704 return isolate_->heap()->undefined_value(); | 704 return isolate_->heap()->undefined_value(); |
| 705 } | 705 } |
| 706 | 706 |
| 707 } } // namespace v8::internal | 707 } } // namespace v8::internal |
| OLD | NEW |