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 <algorithm> | |
8 #include <sstream> | 7 #include <sstream> |
9 | 8 |
10 #include "src/v8.h" | 9 #include "src/v8.h" |
11 | 10 |
12 #include "src/allocation-site-scopes.h" | 11 #include "src/allocation-site-scopes.h" |
13 #include "src/codegen.h" | |
14 #include "src/full-codegen.h" | 12 #include "src/full-codegen.h" |
15 #include "src/hashmap.h" | |
16 #include "src/hydrogen-bce.h" | 13 #include "src/hydrogen-bce.h" |
17 #include "src/hydrogen-bch.h" | 14 #include "src/hydrogen-bch.h" |
18 #include "src/hydrogen-canonicalize.h" | 15 #include "src/hydrogen-canonicalize.h" |
19 #include "src/hydrogen-check-elimination.h" | 16 #include "src/hydrogen-check-elimination.h" |
20 #include "src/hydrogen-dce.h" | 17 #include "src/hydrogen-dce.h" |
21 #include "src/hydrogen-dehoist.h" | 18 #include "src/hydrogen-dehoist.h" |
22 #include "src/hydrogen-environment-liveness.h" | 19 #include "src/hydrogen-environment-liveness.h" |
23 #include "src/hydrogen-escape-analysis.h" | 20 #include "src/hydrogen-escape-analysis.h" |
24 #include "src/hydrogen-gvn.h" | 21 #include "src/hydrogen-gvn.h" |
25 #include "src/hydrogen-infer-representation.h" | 22 #include "src/hydrogen-infer-representation.h" |
(...skipping 10 matching lines...) Expand all Loading... |
36 #include "src/hydrogen-store-elimination.h" | 33 #include "src/hydrogen-store-elimination.h" |
37 #include "src/hydrogen-uint32-analysis.h" | 34 #include "src/hydrogen-uint32-analysis.h" |
38 #include "src/ic/call-optimization.h" | 35 #include "src/ic/call-optimization.h" |
39 #include "src/ic/ic.h" | 36 #include "src/ic/ic.h" |
40 // GetRootConstructor | 37 // GetRootConstructor |
41 #include "src/ic/ic-inl.h" | 38 #include "src/ic/ic-inl.h" |
42 #include "src/lithium-allocator.h" | 39 #include "src/lithium-allocator.h" |
43 #include "src/parser.h" | 40 #include "src/parser.h" |
44 #include "src/runtime/runtime.h" | 41 #include "src/runtime/runtime.h" |
45 #include "src/scopeinfo.h" | 42 #include "src/scopeinfo.h" |
46 #include "src/scopes.h" | |
47 #include "src/typing.h" | 43 #include "src/typing.h" |
48 | 44 |
49 #if V8_TARGET_ARCH_IA32 | 45 #if V8_TARGET_ARCH_IA32 |
50 #include "src/ia32/lithium-codegen-ia32.h" // NOLINT | 46 #include "src/ia32/lithium-codegen-ia32.h" // NOLINT |
51 #elif V8_TARGET_ARCH_X64 | 47 #elif V8_TARGET_ARCH_X64 |
52 #include "src/x64/lithium-codegen-x64.h" // NOLINT | 48 #include "src/x64/lithium-codegen-x64.h" // NOLINT |
53 #elif V8_TARGET_ARCH_ARM64 | 49 #elif V8_TARGET_ARCH_ARM64 |
54 #include "src/arm64/lithium-codegen-arm64.h" // NOLINT | 50 #include "src/arm64/lithium-codegen-arm64.h" // NOLINT |
55 #elif V8_TARGET_ARCH_ARM | 51 #elif V8_TARGET_ARCH_ARM |
56 #include "src/arm/lithium-codegen-arm.h" // NOLINT | 52 #include "src/arm/lithium-codegen-arm.h" // NOLINT |
(...skipping 2839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2896 from_elements_kind); | 2892 from_elements_kind); |
2897 Add<HStoreKeyed>(to_elements, key_constant, value, to_elements_kind); | 2893 Add<HStoreKeyed>(to_elements, key_constant, value, to_elements_kind); |
2898 } | 2894 } |
2899 } else { | 2895 } else { |
2900 if (!pre_fill_with_holes && | 2896 if (!pre_fill_with_holes && |
2901 (capacity == NULL || !length->Equals(capacity))) { | 2897 (capacity == NULL || !length->Equals(capacity))) { |
2902 BuildFillElementsWithHole(to_elements, to_elements_kind, | 2898 BuildFillElementsWithHole(to_elements, to_elements_kind, |
2903 length, NULL); | 2899 length, NULL); |
2904 } | 2900 } |
2905 | 2901 |
2906 if (capacity == NULL) { | |
2907 capacity = AddLoadFixedArrayLength(to_elements); | |
2908 } | |
2909 | |
2910 LoopBuilder builder(this, context(), LoopBuilder::kPostDecrement); | 2902 LoopBuilder builder(this, context(), LoopBuilder::kPostDecrement); |
2911 | 2903 |
2912 HValue* key = builder.BeginBody(length, graph()->GetConstant0(), | 2904 HValue* key = builder.BeginBody(length, graph()->GetConstant0(), |
2913 Token::GT); | 2905 Token::GT); |
2914 | 2906 |
2915 key = AddUncasted<HSub>(key, graph()->GetConstant1()); | 2907 key = AddUncasted<HSub>(key, graph()->GetConstant1()); |
2916 key->ClearFlag(HValue::kCanOverflow); | 2908 key->ClearFlag(HValue::kCanOverflow); |
2917 | 2909 |
2918 HValue* element = Add<HLoadKeyed>(from_elements, key, | 2910 HValue* element = Add<HLoadKeyed>(from_elements, key, |
2919 static_cast<HValue*>(NULL), | 2911 static_cast<HValue*>(NULL), |
(...skipping 3386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6306 | 6298 |
6307 if (i < types->length()) { | 6299 if (i < types->length()) { |
6308 count = -1; | 6300 count = -1; |
6309 types->Clear(); | 6301 types->Clear(); |
6310 } else { | 6302 } else { |
6311 count = 0; | 6303 count = 0; |
6312 } | 6304 } |
6313 HControlInstruction* smi_check = NULL; | 6305 HControlInstruction* smi_check = NULL; |
6314 handled_string = false; | 6306 handled_string = false; |
6315 | 6307 |
6316 for (int i = 0; i < types->length() && count < kMaxLoadPolymorphism; ++i) { | 6308 for (i = 0; i < types->length() && count < kMaxLoadPolymorphism; ++i) { |
6317 PropertyAccessInfo info(this, access_type, ToType(types->at(i)), name); | 6309 PropertyAccessInfo info(this, access_type, ToType(types->at(i)), name); |
6318 if (info.type()->Is(Type::String())) { | 6310 if (info.type()->Is(Type::String())) { |
6319 if (handled_string) continue; | 6311 if (handled_string) continue; |
6320 handled_string = true; | 6312 handled_string = true; |
6321 } | 6313 } |
6322 if (!info.CanAccessMonomorphic()) continue; | 6314 if (!info.CanAccessMonomorphic()) continue; |
6323 | 6315 |
6324 if (count == 0) { | 6316 if (count == 0) { |
6325 join = graph()->CreateBasicBlock(); | 6317 join = graph()->CreateBasicBlock(); |
6326 if (handle_smi) { | 6318 if (handle_smi) { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6384 } | 6376 } |
6385 | 6377 |
6386 if (current_block() != NULL) Goto(join); | 6378 if (current_block() != NULL) Goto(join); |
6387 set_current_block(if_false); | 6379 set_current_block(if_false); |
6388 } | 6380 } |
6389 | 6381 |
6390 // Finish up. Unconditionally deoptimize if we've handled all the maps we | 6382 // Finish up. Unconditionally deoptimize if we've handled all the maps we |
6391 // know about and do not want to handle ones we've never seen. Otherwise | 6383 // know about and do not want to handle ones we've never seen. Otherwise |
6392 // use a generic IC. | 6384 // use a generic IC. |
6393 if (count == types->length() && FLAG_deoptimize_uncommon_cases) { | 6385 if (count == types->length() && FLAG_deoptimize_uncommon_cases) { |
6394 FinishExitWithHardDeoptimization("Uknown map in polymorphic access"); | 6386 FinishExitWithHardDeoptimization("Unknown map in polymorphic access"); |
6395 } else { | 6387 } else { |
6396 HInstruction* instr = BuildNamedGeneric(access_type, expr, object, name, | 6388 HInstruction* instr = BuildNamedGeneric(access_type, expr, object, name, |
6397 value); | 6389 value); |
6398 AddInstruction(instr); | 6390 AddInstruction(instr); |
6399 if (!ast_context()->IsEffect()) Push(access_type == LOAD ? instr : value); | 6391 if (!ast_context()->IsEffect()) Push(access_type == LOAD ? instr : value); |
6400 | 6392 |
6401 if (join != NULL) { | 6393 if (join != NULL) { |
6402 Goto(join); | 6394 Goto(join); |
6403 } else { | 6395 } else { |
6404 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); | 6396 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); |
(...skipping 2699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9104 Variable* var = proxy->var(); | 9096 Variable* var = proxy->var(); |
9105 bool known_global_function = false; | 9097 bool known_global_function = false; |
9106 // If there is a global property cell for the name at compile time and | 9098 // If there is a global property cell for the name at compile time and |
9107 // access check is not enabled we assume that the function will not change | 9099 // access check is not enabled we assume that the function will not change |
9108 // and generate optimized code for calling the function. | 9100 // and generate optimized code for calling the function. |
9109 Handle<GlobalObject> global(current_info()->global_object()); | 9101 Handle<GlobalObject> global(current_info()->global_object()); |
9110 LookupIterator it(global, var->name(), | 9102 LookupIterator it(global, var->name(), |
9111 LookupIterator::OWN_SKIP_INTERCEPTOR); | 9103 LookupIterator::OWN_SKIP_INTERCEPTOR); |
9112 GlobalPropertyAccess type = LookupGlobalProperty(var, &it, LOAD); | 9104 GlobalPropertyAccess type = LookupGlobalProperty(var, &it, LOAD); |
9113 if (type == kUseCell) { | 9105 if (type == kUseCell) { |
9114 Handle<GlobalObject> global(current_info()->global_object()); | |
9115 known_global_function = expr->ComputeGlobalTarget(global, &it); | 9106 known_global_function = expr->ComputeGlobalTarget(global, &it); |
9116 } | 9107 } |
9117 if (known_global_function) { | 9108 if (known_global_function) { |
9118 Add<HCheckValue>(function, expr->target()); | 9109 Add<HCheckValue>(function, expr->target()); |
9119 | 9110 |
9120 // Placeholder for the receiver. | 9111 // Placeholder for the receiver. |
9121 Push(graph()->GetConstantUndefined()); | 9112 Push(graph()->GetConstantUndefined()); |
9122 CHECK_ALIVE(VisitExpressions(expr->arguments())); | 9113 CHECK_ALIVE(VisitExpressions(expr->arguments())); |
9123 | 9114 |
9124 // Patch the global object on the stack by the expected receiver. | 9115 // Patch the global object on the stack by the expected receiver. |
(...skipping 3419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12544 if (ShouldProduceTraceOutput()) { | 12535 if (ShouldProduceTraceOutput()) { |
12545 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 12536 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
12546 } | 12537 } |
12547 | 12538 |
12548 #ifdef DEBUG | 12539 #ifdef DEBUG |
12549 graph_->Verify(false); // No full verify. | 12540 graph_->Verify(false); // No full verify. |
12550 #endif | 12541 #endif |
12551 } | 12542 } |
12552 | 12543 |
12553 } } // namespace v8::internal | 12544 } } // namespace v8::internal |
OLD | NEW |