OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/ast.h" | 7 #include "src/ast.h" |
8 #include "src/ast-numbering.h" | 8 #include "src/ast-numbering.h" |
9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
888 &FullCodeGenerator::Emit##Name, | 888 &FullCodeGenerator::Emit##Name, |
889 | 889 |
890 const FullCodeGenerator::InlineFunctionGenerator | 890 const FullCodeGenerator::InlineFunctionGenerator |
891 FullCodeGenerator::kInlineFunctionGenerators[] = { | 891 FullCodeGenerator::kInlineFunctionGenerators[] = { |
892 INLINE_FUNCTION_LIST(INLINE_FUNCTION_GENERATOR_ADDRESS) | 892 INLINE_FUNCTION_LIST(INLINE_FUNCTION_GENERATOR_ADDRESS) |
893 }; | 893 }; |
894 #undef INLINE_FUNCTION_GENERATOR_ADDRESS | 894 #undef INLINE_FUNCTION_GENERATOR_ADDRESS |
895 | 895 |
896 | 896 |
897 FullCodeGenerator::InlineFunctionGenerator | 897 FullCodeGenerator::InlineFunctionGenerator |
898 FullCodeGenerator::FindInlineFunctionGenerator(Runtime::FunctionId id) { | 898 FullCodeGenerator::FindInlineFunctionGenerator(CallRuntime* expr) { |
899 int lookup_index = | 899 const Runtime::Function* function = expr->function(); |
900 static_cast<int>(id) - static_cast<int>(Runtime::kFirstInlineFunction); | 900 if (function == nullptr || function->intrinsic_type != Runtime::INLINE) { |
901 DCHECK(lookup_index >= 0); | 901 return nullptr; |
902 DCHECK(static_cast<size_t>(lookup_index) < | 902 } |
903 arraysize(kInlineFunctionGenerators)); | 903 Runtime::FunctionId id = function->function_id; |
904 return kInlineFunctionGenerators[lookup_index]; | 904 if (id < Runtime::kFirstInlineFunction || Runtime::kLastInlineFunction < id) { |
| 905 return nullptr; |
| 906 } |
| 907 return kInlineFunctionGenerators[static_cast<int>(id) - |
| 908 static_cast<int>( |
| 909 Runtime::kFirstInlineFunction)]; |
905 } | 910 } |
906 | 911 |
907 | 912 |
908 void FullCodeGenerator::EmitInlineRuntimeCall(CallRuntime* expr) { | 913 void FullCodeGenerator::EmitInlineRuntimeCall( |
909 const Runtime::Function* function = expr->function(); | 914 CallRuntime* expr, InlineFunctionGenerator generator) { |
910 DCHECK(function != NULL); | |
911 DCHECK(function->intrinsic_type == Runtime::INLINE); | |
912 InlineFunctionGenerator generator = | |
913 FindInlineFunctionGenerator(function->function_id); | |
914 ((*this).*(generator))(expr); | 915 ((*this).*(generator))(expr); |
915 } | 916 } |
916 | 917 |
917 | 918 |
918 void FullCodeGenerator::EmitGeneratorNext(CallRuntime* expr) { | 919 void FullCodeGenerator::EmitGeneratorNext(CallRuntime* expr) { |
919 ZoneList<Expression*>* args = expr->arguments(); | 920 ZoneList<Expression*>* args = expr->arguments(); |
920 DCHECK(args->length() == 2); | 921 DCHECK(args->length() == 2); |
921 EmitGeneratorResume(args->at(0), args->at(1), JSGeneratorObject::NEXT); | 922 EmitGeneratorResume(args->at(0), args->at(1), JSGeneratorObject::NEXT); |
922 } | 923 } |
923 | 924 |
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1817 } | 1818 } |
1818 codegen_->PrepareForBailoutForId(exit_id_, NO_REGISTERS); | 1819 codegen_->PrepareForBailoutForId(exit_id_, NO_REGISTERS); |
1819 codegen_->scope_ = saved_scope_; | 1820 codegen_->scope_ = saved_scope_; |
1820 } | 1821 } |
1821 | 1822 |
1822 | 1823 |
1823 #undef __ | 1824 #undef __ |
1824 | 1825 |
1825 | 1826 |
1826 } } // namespace v8::internal | 1827 } } // namespace v8::internal |
OLD | NEW |