OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 7926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7937 | 7937 |
7938 | 7938 |
7939 void HOptimizedGraphBuilder::BuildInlinedCallNewArray(CallNew* expr) { | 7939 void HOptimizedGraphBuilder::BuildInlinedCallNewArray(CallNew* expr) { |
7940 NoObservableSideEffectsScope no_effects(this); | 7940 NoObservableSideEffectsScope no_effects(this); |
7941 | 7941 |
7942 int argument_count = expr->arguments()->length(); | 7942 int argument_count = expr->arguments()->length(); |
7943 // We should at least have the constructor on the expression stack. | 7943 // We should at least have the constructor on the expression stack. |
7944 HValue* constructor = environment()->ExpressionStackAt(argument_count); | 7944 HValue* constructor = environment()->ExpressionStackAt(argument_count); |
7945 | 7945 |
7946 ElementsKind kind = expr->elements_kind(); | 7946 ElementsKind kind = expr->elements_kind(); |
7947 Handle<Cell> cell = expr->allocation_info_cell(); | 7947 Handle<AllocationSite> site = expr->allocation_site(); |
7948 Handle<AllocationSite> site(AllocationSite::cast(cell->value())); | 7948 ASSERT(!site.is_null()); |
7949 | 7949 |
7950 // Register on the site for deoptimization if the transition feedback changes. | 7950 // Register on the site for deoptimization if the transition feedback changes. |
7951 AllocationSite::AddDependentCompilationInfo( | 7951 AllocationSite::AddDependentCompilationInfo( |
7952 site, AllocationSite::TRANSITIONS, top_info()); | 7952 site, AllocationSite::TRANSITIONS, top_info()); |
7953 HInstruction* site_instruction = Add<HConstant>(site); | 7953 HInstruction* site_instruction = Add<HConstant>(site); |
7954 | 7954 |
7955 // In the single constant argument case, we may have to adjust elements kind | 7955 // In the single constant argument case, we may have to adjust elements kind |
7956 // to avoid creating a packed non-empty array. | 7956 // to avoid creating a packed non-empty array. |
7957 if (argument_count == 1 && !IsHoleyElementsKind(kind)) { | 7957 if (argument_count == 1 && !IsHoleyElementsKind(kind)) { |
7958 HValue* argument = environment()->Top(); | 7958 HValue* argument = environment()->Top(); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8012 | 8012 |
8013 | 8013 |
8014 bool HOptimizedGraphBuilder::IsCallNewArrayInlineable(CallNew* expr) { | 8014 bool HOptimizedGraphBuilder::IsCallNewArrayInlineable(CallNew* expr) { |
8015 bool inline_ok = false; | 8015 bool inline_ok = false; |
8016 Handle<JSFunction> caller = current_info()->closure(); | 8016 Handle<JSFunction> caller = current_info()->closure(); |
8017 Handle<JSFunction> target(isolate()->global_context()->array_function(), | 8017 Handle<JSFunction> target(isolate()->global_context()->array_function(), |
8018 isolate()); | 8018 isolate()); |
8019 int argument_count = expr->arguments()->length(); | 8019 int argument_count = expr->arguments()->length(); |
8020 // We should have the function plus array arguments on the environment stack. | 8020 // We should have the function plus array arguments on the environment stack. |
8021 ASSERT(environment()->length() >= (argument_count + 1)); | 8021 ASSERT(environment()->length() >= (argument_count + 1)); |
8022 Handle<Cell> cell = expr->allocation_info_cell(); | 8022 Handle<AllocationSite> site = expr->allocation_site(); |
8023 AllocationSite* site = AllocationSite::cast(cell->value()); | 8023 ASSERT(!site.is_null()); |
| 8024 |
8024 if (site->CanInlineCall()) { | 8025 if (site->CanInlineCall()) { |
8025 // We also want to avoid inlining in certain 1 argument scenarios. | 8026 // We also want to avoid inlining in certain 1 argument scenarios. |
8026 if (argument_count == 1) { | 8027 if (argument_count == 1) { |
8027 HValue* argument = Top(); | 8028 HValue* argument = Top(); |
8028 if (argument->IsConstant()) { | 8029 if (argument->IsConstant()) { |
8029 // Do not inline if the constant length argument is not a smi or | 8030 // Do not inline if the constant length argument is not a smi or |
8030 // outside the valid range for a fast array. | 8031 // outside the valid range for a fast array. |
8031 HConstant* constant_argument = HConstant::cast(argument); | 8032 HConstant* constant_argument = HConstant::cast(argument); |
8032 if (constant_argument->HasSmiValue()) { | 8033 if (constant_argument->HasSmiValue()) { |
8033 int value = constant_argument->Integer32Value(); | 8034 int value = constant_argument->Integer32Value(); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8152 environment()->SetExpressionStackAt(receiver_index, function); | 8153 environment()->SetExpressionStackAt(receiver_index, function); |
8153 HInstruction* call = | 8154 HInstruction* call = |
8154 PreProcessCall(New<HCallNew>(function, argument_count)); | 8155 PreProcessCall(New<HCallNew>(function, argument_count)); |
8155 return ast_context()->ReturnInstruction(call, expr->id()); | 8156 return ast_context()->ReturnInstruction(call, expr->id()); |
8156 } else { | 8157 } else { |
8157 // The constructor function is both an operand to the instruction and an | 8158 // The constructor function is both an operand to the instruction and an |
8158 // argument to the construct call. | 8159 // argument to the construct call. |
8159 Handle<JSFunction> array_function( | 8160 Handle<JSFunction> array_function( |
8160 isolate()->global_context()->array_function(), isolate()); | 8161 isolate()->global_context()->array_function(), isolate()); |
8161 bool use_call_new_array = expr->target().is_identical_to(array_function); | 8162 bool use_call_new_array = expr->target().is_identical_to(array_function); |
8162 Handle<Cell> cell = expr->allocation_info_cell(); | |
8163 if (use_call_new_array && IsCallNewArrayInlineable(expr)) { | 8163 if (use_call_new_array && IsCallNewArrayInlineable(expr)) { |
8164 // Verify we are still calling the array function for our native context. | 8164 // Verify we are still calling the array function for our native context. |
8165 Add<HCheckValue>(function, array_function); | 8165 Add<HCheckValue>(function, array_function); |
8166 BuildInlinedCallNewArray(expr); | 8166 BuildInlinedCallNewArray(expr); |
8167 return; | 8167 return; |
8168 } | 8168 } |
8169 | 8169 |
8170 HBinaryCall* call; | 8170 HBinaryCall* call; |
8171 if (use_call_new_array) { | 8171 if (use_call_new_array) { |
8172 Add<HCheckValue>(function, array_function); | 8172 Add<HCheckValue>(function, array_function); |
8173 call = New<HCallNewArray>(function, argument_count, cell, | 8173 call = New<HCallNewArray>(function, argument_count, |
8174 expr->elements_kind()); | 8174 expr->elements_kind()); |
8175 } else { | 8175 } else { |
8176 call = New<HCallNew>(function, argument_count); | 8176 call = New<HCallNew>(function, argument_count); |
8177 } | 8177 } |
8178 PreProcessCall(call); | 8178 PreProcessCall(call); |
8179 return ast_context()->ReturnInstruction(call, expr->id()); | 8179 return ast_context()->ReturnInstruction(call, expr->id()); |
8180 } | 8180 } |
8181 } | 8181 } |
8182 | 8182 |
8183 | 8183 |
(...skipping 2822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11006 if (ShouldProduceTraceOutput()) { | 11006 if (ShouldProduceTraceOutput()) { |
11007 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 11007 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
11008 } | 11008 } |
11009 | 11009 |
11010 #ifdef DEBUG | 11010 #ifdef DEBUG |
11011 graph_->Verify(false); // No full verify. | 11011 graph_->Verify(false); // No full verify. |
11012 #endif | 11012 #endif |
11013 } | 11013 } |
11014 | 11014 |
11015 } } // namespace v8::internal | 11015 } } // namespace v8::internal |
OLD | NEW |