OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/hydrogen.h" | 5 #include "src/hydrogen.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "src/v8.h" | 9 #include "src/v8.h" |
10 | 10 |
(...skipping 9517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9528 &HOptimizedGraphBuilder::Generate##Name, | 9528 &HOptimizedGraphBuilder::Generate##Name, |
9529 | 9529 |
9530 const HOptimizedGraphBuilder::InlineFunctionGenerator | 9530 const HOptimizedGraphBuilder::InlineFunctionGenerator |
9531 HOptimizedGraphBuilder::kInlineFunctionGenerators[] = { | 9531 HOptimizedGraphBuilder::kInlineFunctionGenerators[] = { |
9532 INLINE_FUNCTION_LIST(INLINE_FUNCTION_GENERATOR_ADDRESS) | 9532 INLINE_FUNCTION_LIST(INLINE_FUNCTION_GENERATOR_ADDRESS) |
9533 INLINE_OPTIMIZED_FUNCTION_LIST(INLINE_FUNCTION_GENERATOR_ADDRESS) | 9533 INLINE_OPTIMIZED_FUNCTION_LIST(INLINE_FUNCTION_GENERATOR_ADDRESS) |
9534 }; | 9534 }; |
9535 #undef INLINE_FUNCTION_GENERATOR_ADDRESS | 9535 #undef INLINE_FUNCTION_GENERATOR_ADDRESS |
9536 | 9536 |
9537 | 9537 |
| 9538 HOptimizedGraphBuilder::InlineFunctionGenerator |
| 9539 HOptimizedGraphBuilder::FindInlineFunctionGenerator(CallRuntime* expr) { |
| 9540 const Runtime::Function* function = expr->function(); |
| 9541 if (function == nullptr || function->intrinsic_type != Runtime::INLINE) { |
| 9542 return nullptr; |
| 9543 } |
| 9544 Runtime::FunctionId id = function->function_id; |
| 9545 if (id < Runtime::kFirstInlineFunction) return nullptr; |
| 9546 int lookup_index = |
| 9547 static_cast<int>(id) - static_cast<int>(Runtime::kFirstInlineFunction); |
| 9548 DCHECK(static_cast<size_t>(lookup_index) < |
| 9549 arraysize(kInlineFunctionGenerators)); |
| 9550 return kInlineFunctionGenerators[lookup_index]; |
| 9551 } |
| 9552 |
| 9553 |
9538 template <class ViewClass> | 9554 template <class ViewClass> |
9539 void HGraphBuilder::BuildArrayBufferViewInitialization( | 9555 void HGraphBuilder::BuildArrayBufferViewInitialization( |
9540 HValue* obj, | 9556 HValue* obj, |
9541 HValue* buffer, | 9557 HValue* buffer, |
9542 HValue* byte_offset, | 9558 HValue* byte_offset, |
9543 HValue* byte_length) { | 9559 HValue* byte_length) { |
9544 | 9560 |
9545 for (int offset = ViewClass::kSize; | 9561 for (int offset = ViewClass::kSize; |
9546 offset < ViewClass::kSizeWithInternalFields; | 9562 offset < ViewClass::kSizeWithInternalFields; |
9547 offset += kPointerSize) { | 9563 offset += kPointerSize) { |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9907 DCHECK(!HasStackOverflow()); | 9923 DCHECK(!HasStackOverflow()); |
9908 DCHECK(current_block() != NULL); | 9924 DCHECK(current_block() != NULL); |
9909 DCHECK(current_block()->HasPredecessor()); | 9925 DCHECK(current_block()->HasPredecessor()); |
9910 if (expr->is_jsruntime()) { | 9926 if (expr->is_jsruntime()) { |
9911 return Bailout(kCallToAJavaScriptRuntimeFunction); | 9927 return Bailout(kCallToAJavaScriptRuntimeFunction); |
9912 } | 9928 } |
9913 | 9929 |
9914 const Runtime::Function* function = expr->function(); | 9930 const Runtime::Function* function = expr->function(); |
9915 DCHECK(function != NULL); | 9931 DCHECK(function != NULL); |
9916 | 9932 |
9917 if (function->intrinsic_type == Runtime::INLINE) { | 9933 InlineFunctionGenerator generator = FindInlineFunctionGenerator(expr); |
| 9934 if (generator != nullptr) { |
9918 DCHECK(expr->name()->length() > 0); | 9935 DCHECK(expr->name()->length() > 0); |
9919 DCHECK(expr->name()->Get(0) == '_'); | 9936 DCHECK(expr->name()->Get(0) == '_'); |
9920 // Call to an inline function. | |
9921 int lookup_index = static_cast<int>(function->function_id) - | |
9922 static_cast<int>(Runtime::kFirstInlineFunction); | |
9923 DCHECK(lookup_index >= 0); | |
9924 DCHECK(static_cast<size_t>(lookup_index) < | |
9925 arraysize(kInlineFunctionGenerators)); | |
9926 InlineFunctionGenerator generator = kInlineFunctionGenerators[lookup_index]; | |
9927 | |
9928 // Call the inline code generator using the pointer-to-member. | 9937 // Call the inline code generator using the pointer-to-member. |
9929 (this->*generator)(expr); | 9938 (this->*generator)(expr); |
9930 } else { | 9939 } else { |
9931 DCHECK(function->intrinsic_type == Runtime::RUNTIME); | |
9932 Handle<String> name = expr->name(); | 9940 Handle<String> name = expr->name(); |
9933 int argument_count = expr->arguments()->length(); | 9941 int argument_count = expr->arguments()->length(); |
9934 CHECK_ALIVE(VisitExpressions(expr->arguments())); | 9942 CHECK_ALIVE(VisitExpressions(expr->arguments())); |
9935 PushArgumentsFromEnvironment(argument_count); | 9943 PushArgumentsFromEnvironment(argument_count); |
9936 HCallRuntime* call = New<HCallRuntime>(name, function, | 9944 HCallRuntime* call = New<HCallRuntime>(name, function, |
9937 argument_count); | 9945 argument_count); |
9938 return ast_context()->ReturnInstruction(call, expr->id()); | 9946 return ast_context()->ReturnInstruction(call, expr->id()); |
9939 } | 9947 } |
9940 } | 9948 } |
9941 | 9949 |
(...skipping 3472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13414 if (ShouldProduceTraceOutput()) { | 13422 if (ShouldProduceTraceOutput()) { |
13415 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13423 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
13416 } | 13424 } |
13417 | 13425 |
13418 #ifdef DEBUG | 13426 #ifdef DEBUG |
13419 graph_->Verify(false); // No full verify. | 13427 graph_->Verify(false); // No full verify. |
13420 #endif | 13428 #endif |
13421 } | 13429 } |
13422 | 13430 |
13423 } } // namespace v8::internal | 13431 } } // namespace v8::internal |
OLD | NEW |