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> | 7 #include <algorithm> |
8 | 8 |
9 #include "src/v8.h" | 9 #include "src/v8.h" |
10 | 10 |
(...skipping 6252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6263 SmallMapList* types, | 6263 SmallMapList* types, |
6264 Handle<String> name) { | 6264 Handle<String> name) { |
6265 // Something did not match; must use a polymorphic load. | 6265 // Something did not match; must use a polymorphic load. |
6266 int count = 0; | 6266 int count = 0; |
6267 HBasicBlock* join = NULL; | 6267 HBasicBlock* join = NULL; |
6268 HBasicBlock* number_block = NULL; | 6268 HBasicBlock* number_block = NULL; |
6269 bool handled_string = false; | 6269 bool handled_string = false; |
6270 | 6270 |
6271 bool handle_smi = false; | 6271 bool handle_smi = false; |
6272 STATIC_ASSERT(kMaxLoadPolymorphism == kMaxStorePolymorphism); | 6272 STATIC_ASSERT(kMaxLoadPolymorphism == kMaxStorePolymorphism); |
6273 for (int i = 0; i < types->length() && count < kMaxLoadPolymorphism; ++i) { | 6273 int i; |
6274 for (i = 0; i < types->length() && count < kMaxLoadPolymorphism; ++i) { | |
6274 PropertyAccessInfo info(this, access_type, ToType(types->at(i)), name); | 6275 PropertyAccessInfo info(this, access_type, ToType(types->at(i)), name); |
6275 if (info.type()->Is(Type::String())) { | 6276 if (info.type()->Is(Type::String())) { |
6276 if (handled_string) continue; | 6277 if (handled_string) continue; |
6277 handled_string = true; | 6278 handled_string = true; |
6278 } | 6279 } |
6279 if (info.CanAccessMonomorphic()) { | 6280 if (info.CanAccessMonomorphic()) { |
6280 count++; | 6281 count++; |
6281 if (info.type()->Is(Type::Number())) { | 6282 if (info.type()->Is(Type::Number())) { |
6282 handle_smi = true; | 6283 handle_smi = true; |
6283 break; | 6284 break; |
6284 } | 6285 } |
6285 } | 6286 } |
6286 } | 6287 } |
6287 | 6288 |
6288 count = 0; | 6289 if (i < types->length()) { |
6290 count = -1; | |
6291 types->Clear(); | |
6292 } else { | |
6293 count = 0; | |
6294 } | |
6289 HControlInstruction* smi_check = NULL; | 6295 HControlInstruction* smi_check = NULL; |
6290 handled_string = false; | 6296 handled_string = false; |
6291 | 6297 |
6298 | |
Jakob Kummerow
2014/09/18 09:48:45
nit: unnecessary empty line
| |
6292 for (int i = 0; i < types->length() && count < kMaxLoadPolymorphism; ++i) { | 6299 for (int i = 0; i < types->length() && count < kMaxLoadPolymorphism; ++i) { |
6293 PropertyAccessInfo info(this, access_type, ToType(types->at(i)), name); | 6300 PropertyAccessInfo info(this, access_type, ToType(types->at(i)), name); |
6294 if (info.type()->Is(Type::String())) { | 6301 if (info.type()->Is(Type::String())) { |
6295 if (handled_string) continue; | 6302 if (handled_string) continue; |
6296 handled_string = true; | 6303 handled_string = true; |
6297 } | 6304 } |
6298 if (!info.CanAccessMonomorphic()) continue; | 6305 if (!info.CanAccessMonomorphic()) continue; |
6299 | 6306 |
6300 if (count == 0) { | 6307 if (count == 0) { |
6301 join = graph()->CreateBasicBlock(); | 6308 join = graph()->CreateBasicBlock(); |
(...skipping 1187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7489 HValue* receiver, | 7496 HValue* receiver, |
7490 SmallMapList* types, | 7497 SmallMapList* types, |
7491 Handle<String> name) { | 7498 Handle<String> name) { |
7492 int argument_count = expr->arguments()->length() + 1; // Includes receiver. | 7499 int argument_count = expr->arguments()->length() + 1; // Includes receiver. |
7493 FunctionSorter order[kMaxCallPolymorphism]; | 7500 FunctionSorter order[kMaxCallPolymorphism]; |
7494 | 7501 |
7495 bool handle_smi = false; | 7502 bool handle_smi = false; |
7496 bool handled_string = false; | 7503 bool handled_string = false; |
7497 int ordered_functions = 0; | 7504 int ordered_functions = 0; |
7498 | 7505 |
7499 for (int i = 0; | 7506 int i; |
7500 i < types->length() && ordered_functions < kMaxCallPolymorphism; | 7507 for (i = 0; i < types->length() && ordered_functions < kMaxCallPolymorphism; |
7501 ++i) { | 7508 ++i) { |
7502 PropertyAccessInfo info(this, LOAD, ToType(types->at(i)), name); | 7509 PropertyAccessInfo info(this, LOAD, ToType(types->at(i)), name); |
7503 if (info.CanAccessMonomorphic() && info.IsConstant() && | 7510 if (info.CanAccessMonomorphic() && info.IsConstant() && |
7504 info.constant()->IsJSFunction()) { | 7511 info.constant()->IsJSFunction()) { |
7505 if (info.type()->Is(Type::String())) { | 7512 if (info.type()->Is(Type::String())) { |
7506 if (handled_string) continue; | 7513 if (handled_string) continue; |
7507 handled_string = true; | 7514 handled_string = true; |
7508 } | 7515 } |
7509 Handle<JSFunction> target = Handle<JSFunction>::cast(info.constant()); | 7516 Handle<JSFunction> target = Handle<JSFunction>::cast(info.constant()); |
7510 if (info.type()->Is(Type::Number())) { | 7517 if (info.type()->Is(Type::Number())) { |
7511 handle_smi = true; | 7518 handle_smi = true; |
7512 } | 7519 } |
7513 expr->set_target(target); | 7520 expr->set_target(target); |
7514 order[ordered_functions++] = FunctionSorter( | 7521 order[ordered_functions++] = FunctionSorter( |
7515 i, target->shared()->profiler_ticks(), InliningAstSize(target)); | 7522 i, target->shared()->profiler_ticks(), InliningAstSize(target)); |
7516 } | 7523 } |
7517 } | 7524 } |
7518 | 7525 |
7519 std::sort(order, order + ordered_functions); | 7526 std::sort(order, order + ordered_functions); |
7520 | 7527 |
7528 if (i < types->length()) { | |
7529 types->Clear(); | |
7530 ordered_functions = -1; | |
7531 } | |
7532 | |
7521 HBasicBlock* number_block = NULL; | 7533 HBasicBlock* number_block = NULL; |
7522 HBasicBlock* join = NULL; | 7534 HBasicBlock* join = NULL; |
7523 handled_string = false; | 7535 handled_string = false; |
7524 int count = 0; | 7536 int count = 0; |
7525 | 7537 |
7526 for (int fn = 0; fn < ordered_functions; ++fn) { | 7538 for (int fn = 0; fn < ordered_functions; ++fn) { |
7527 int i = order[fn].index(); | 7539 int i = order[fn].index(); |
7528 PropertyAccessInfo info(this, LOAD, ToType(types->at(i)), name); | 7540 PropertyAccessInfo info(this, LOAD, ToType(types->at(i)), name); |
7529 if (info.type()->Is(Type::String())) { | 7541 if (info.type()->Is(Type::String())) { |
7530 if (handled_string) continue; | 7542 if (handled_string) continue; |
(...skipping 4973 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12504 if (ShouldProduceTraceOutput()) { | 12516 if (ShouldProduceTraceOutput()) { |
12505 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 12517 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
12506 } | 12518 } |
12507 | 12519 |
12508 #ifdef DEBUG | 12520 #ifdef DEBUG |
12509 graph_->Verify(false); // No full verify. | 12521 graph_->Verify(false); // No full verify. |
12510 #endif | 12522 #endif |
12511 } | 12523 } |
12512 | 12524 |
12513 } } // namespace v8::internal | 12525 } } // namespace v8::internal |
OLD | NEW |