| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. |
| 6 #if defined(TARGET_ARCH_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
| 7 | 7 |
| 8 #include "vm/opt_code_generator.h" | 8 #include "vm/opt_code_generator.h" |
| 9 | 9 |
| 10 #include "vm/assembler_macros.h" | 10 #include "vm/assembler_macros.h" |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 __ call(&StubCode::DeoptimizeLabel()); | 376 __ call(&StubCode::DeoptimizeLabel()); |
| 377 AddCurrentDescriptor(PcDescriptors::kOther, node_id, token_index); | 377 AddCurrentDescriptor(PcDescriptors::kOther, node_id, token_index); |
| 378 #if defined(DEBUG) | 378 #if defined(DEBUG) |
| 379 __ int3(); | 379 __ int3(); |
| 380 #endif | 380 #endif |
| 381 } | 381 } |
| 382 | 382 |
| 383 | 383 |
| 384 // Quick loads do not clobber registers. | 384 // Quick loads do not clobber registers. |
| 385 static bool IsQuickLoad(AstNode* node) { | 385 static bool IsQuickLoad(AstNode* node) { |
| 386 return node->IsLoadLocalNode() || node->IsLiteralNode(); | 386 if (node->IsLoadLocalNode() && (!node->AsLoadLocalNode()->HasPseudo())) { |
| 387 return true; |
| 388 } |
| 389 return node->IsLiteralNode(); |
| 387 } | 390 } |
| 388 | 391 |
| 389 | 392 |
| 390 // Method is closely tied to "VisitLoadTwo". | 393 // Method is closely tied to "VisitLoadTwo". |
| 391 void OptimizingCodeGenerator::VisitLoadOne(AstNode* node, Register reg) { | 394 void OptimizingCodeGenerator::VisitLoadOne(AstNode* node, Register reg) { |
| 392 if (!IsQuickLoad(node)) { | 395 if (!IsQuickLoad(node)) { |
| 393 node->Visit(this); | 396 node->Visit(this); |
| 394 __ popl(reg); | 397 __ popl(reg); |
| 395 return; | 398 return; |
| 396 } | 399 } |
| 397 if (node->AsLoadLocalNode()) { | 400 if (node->IsLoadLocalNode()) { |
| 398 LoadLocalNode* local_node = node->AsLoadLocalNode(); | 401 LoadLocalNode* local_node = node->AsLoadLocalNode(); |
| 399 ASSERT(local_node != NULL); | 402 ASSERT(local_node != NULL); |
| 400 GenerateLoadVariable(reg, local_node->local()); | 403 GenerateLoadVariable(reg, local_node->local()); |
| 401 if (node->info() != NULL) { | 404 if (node->info() != NULL) { |
| 402 const Class* cls = NULL; | 405 const Class* cls = NULL; |
| 403 classes_for_locals_->GetLocalClass(local_node->local(), &cls); | 406 classes_for_locals_->GetLocalClass(local_node->local(), &cls); |
| 404 if (cls != NULL) { | 407 if (cls != NULL) { |
| 405 node->info()->set_is_class(cls); | 408 node->info()->set_is_class(cls); |
| 406 } | 409 } |
| 407 } | 410 } |
| 408 return; | 411 return; |
| 409 } | 412 } |
| 410 if (node->AsLiteralNode()) { | 413 if (node->IsLiteralNode()) { |
| 411 LiteralNode* literal_node = node->AsLiteralNode(); | 414 LiteralNode* literal_node = node->AsLiteralNode(); |
| 412 ASSERT(literal_node != NULL); | 415 ASSERT(literal_node != NULL); |
| 413 __ LoadObject(reg, literal_node->literal()); | 416 __ LoadObject(reg, literal_node->literal()); |
| 414 if (node->info() != NULL) { | 417 if (node->info() != NULL) { |
| 415 const Object& literal = literal_node->literal(); | 418 const Object& literal = literal_node->literal(); |
| 416 if (literal.IsSmi()) { | 419 if (literal.IsSmi()) { |
| 417 node->info()->set_is_class(&smi_class_); | 420 node->info()->set_is_class(&smi_class_); |
| 418 } else if (literal.IsDouble()) { | 421 } else if (literal.IsDouble()) { |
| 419 node->info()->set_is_class(&double_class_); | 422 node->info()->set_is_class(&double_class_); |
| 420 } | 423 } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 __ LoadObject(EAX, literal); | 479 __ LoadObject(EAX, literal); |
| 477 node->info()->set_result_returned_in_eax(true); | 480 node->info()->set_result_returned_in_eax(true); |
| 478 } else { | 481 } else { |
| 479 __ PushObject(literal); | 482 __ PushObject(literal); |
| 480 } | 483 } |
| 481 } | 484 } |
| 482 } | 485 } |
| 483 | 486 |
| 484 | 487 |
| 485 void OptimizingCodeGenerator::VisitLoadLocalNode(LoadLocalNode* node) { | 488 void OptimizingCodeGenerator::VisitLoadLocalNode(LoadLocalNode* node) { |
| 489 if (node->HasPseudo()) { |
| 490 node->pseudo()->Visit(this); |
| 491 __ popl(EAX); |
| 492 } |
| 486 if (!IsResultNeeded(node)) return; | 493 if (!IsResultNeeded(node)) return; |
| 487 if (IsResultInEaxRequested(node)) { | 494 if (IsResultInEaxRequested(node)) { |
| 488 GenerateLoadVariable(EAX, node->local()); | 495 GenerateLoadVariable(EAX, node->local()); |
| 489 node->info()->set_result_returned_in_eax(true); | 496 node->info()->set_result_returned_in_eax(true); |
| 490 } else { | 497 } else { |
| 491 GeneratePushVariable(node->local(), EAX); | 498 GeneratePushVariable(node->local(), EAX); |
| 492 } | 499 } |
| 493 if (node->info() != NULL) { | 500 if (node->info() != NULL) { |
| 494 const Class* cls = NULL; | 501 const Class* cls = NULL; |
| 495 classes_for_locals_->GetLocalClass(node->local(), &cls); | 502 classes_for_locals_->GetLocalClass(node->local(), &cls); |
| (...skipping 2588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3084 } | 3091 } |
| 3085 } | 3092 } |
| 3086 // TODO(srdjan): Implement unary kSUB (negate) Mint. | 3093 // TODO(srdjan): Implement unary kSUB (negate) Mint. |
| 3087 CodeGenerator::VisitUnaryOpNode(node); | 3094 CodeGenerator::VisitUnaryOpNode(node); |
| 3088 } | 3095 } |
| 3089 | 3096 |
| 3090 | 3097 |
| 3091 } // namespace dart | 3098 } // namespace dart |
| 3092 | 3099 |
| 3093 #endif // defined TARGET_ARCH_IA32 | 3100 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |