| 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 "execution.h" | 5 #include "execution.h" |
| 6 | 6 |
| 7 #include "bootstrapper.h" | 7 #include "bootstrapper.h" |
| 8 #include "codegen.h" | 8 #include "codegen.h" |
| 9 #include "deoptimizer.h" | 9 #include "deoptimizer.h" |
| 10 #include "isolate-inl.h" | 10 #include "isolate-inl.h" |
| (...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 Handle<Object> Execution::CharAt(Handle<String> string, uint32_t index) { | 724 Handle<Object> Execution::CharAt(Handle<String> string, uint32_t index) { |
| 725 Isolate* isolate = string->GetIsolate(); | 725 Isolate* isolate = string->GetIsolate(); |
| 726 Factory* factory = isolate->factory(); | 726 Factory* factory = isolate->factory(); |
| 727 | 727 |
| 728 int int_index = static_cast<int>(index); | 728 int int_index = static_cast<int>(index); |
| 729 if (int_index < 0 || int_index >= string->length()) { | 729 if (int_index < 0 || int_index >= string->length()) { |
| 730 return factory->undefined_value(); | 730 return factory->undefined_value(); |
| 731 } | 731 } |
| 732 | 732 |
| 733 Handle<Object> char_at = Object::GetProperty( | 733 Handle<Object> char_at = Object::GetProperty( |
| 734 isolate->js_builtins_object(), | 734 isolate->js_builtins_object(), factory->char_at_string()); |
| 735 factory->char_at_string()).ToHandleChecked(); | |
| 736 if (!char_at->IsJSFunction()) { | 735 if (!char_at->IsJSFunction()) { |
| 737 return factory->undefined_value(); | 736 return factory->undefined_value(); |
| 738 } | 737 } |
| 739 | 738 |
| 740 Handle<Object> index_object = factory->NewNumberFromInt(int_index); | 739 Handle<Object> index_object = factory->NewNumberFromInt(int_index); |
| 741 Handle<Object> index_arg[] = { index_object }; | 740 Handle<Object> index_arg[] = { index_object }; |
| 742 Handle<Object> result; | 741 Handle<Object> result; |
| 743 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 742 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
| 744 isolate, result, | 743 isolate, result, |
| 745 TryCall(Handle<JSFunction>::cast(char_at), | 744 TryCall(Handle<JSFunction>::cast(char_at), |
| 746 string, | 745 string, |
| 747 ARRAY_SIZE(index_arg), | 746 ARRAY_SIZE(index_arg), |
| 748 index_arg), | 747 index_arg), |
| 749 factory->undefined_value()); | 748 factory->undefined_value()); |
| 750 return result; | 749 return result; |
| 751 } | 750 } |
| 752 | 751 |
| 753 | 752 |
| 754 MaybeHandle<JSFunction> Execution::InstantiateFunction( | 753 MaybeHandle<JSFunction> Execution::InstantiateFunction( |
| 755 Handle<FunctionTemplateInfo> data) { | 754 Handle<FunctionTemplateInfo> data) { |
| 756 Isolate* isolate = data->GetIsolate(); | 755 Isolate* isolate = data->GetIsolate(); |
| 757 if (!data->do_not_cache()) { | 756 if (!data->do_not_cache()) { |
| 758 // Fast case: see if the function has already been instantiated | 757 // Fast case: see if the function has already been instantiated |
| 759 int serial_number = Smi::cast(data->serial_number())->value(); | 758 int serial_number = Smi::cast(data->serial_number())->value(); |
| 760 Handle<JSObject> cache(isolate->native_context()->function_cache()); | 759 Handle<JSObject> cache(isolate->native_context()->function_cache()); |
| 761 Handle<Object> elm = | 760 Handle<Object> elm = |
| 762 Object::GetElement(isolate, cache, serial_number).ToHandleChecked(); | 761 Object::GetElementNoExceptionThrown(isolate, cache, serial_number); |
| 763 if (elm->IsJSFunction()) return Handle<JSFunction>::cast(elm); | 762 if (elm->IsJSFunction()) return Handle<JSFunction>::cast(elm); |
| 764 } | 763 } |
| 765 // The function has not yet been instantiated in this context; do it. | 764 // The function has not yet been instantiated in this context; do it. |
| 766 Handle<Object> args[] = { data }; | 765 Handle<Object> args[] = { data }; |
| 767 Handle<Object> result; | 766 Handle<Object> result; |
| 768 ASSIGN_RETURN_ON_EXCEPTION( | 767 ASSIGN_RETURN_ON_EXCEPTION( |
| 769 isolate, result, | 768 isolate, result, |
| 770 Call(isolate, | 769 Call(isolate, |
| 771 isolate->instantiate_fun(), | 770 isolate->instantiate_fun(), |
| 772 isolate->js_builtins_object(), | 771 isolate->js_builtins_object(), |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 986 if (stack_guard->IsInstallCodeRequest()) { | 985 if (stack_guard->IsInstallCodeRequest()) { |
| 987 ASSERT(isolate->concurrent_recompilation_enabled()); | 986 ASSERT(isolate->concurrent_recompilation_enabled()); |
| 988 stack_guard->Continue(INSTALL_CODE); | 987 stack_guard->Continue(INSTALL_CODE); |
| 989 isolate->optimizing_compiler_thread()->InstallOptimizedFunctions(); | 988 isolate->optimizing_compiler_thread()->InstallOptimizedFunctions(); |
| 990 } | 989 } |
| 991 isolate->runtime_profiler()->OptimizeNow(); | 990 isolate->runtime_profiler()->OptimizeNow(); |
| 992 return isolate->heap()->undefined_value(); | 991 return isolate->heap()->undefined_value(); |
| 993 } | 992 } |
| 994 | 993 |
| 995 } } // namespace v8::internal | 994 } } // namespace v8::internal |
| OLD | NEW |