| 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/code_generator.h" | 8 #include "vm/code_generator.h" |
| 9 | 9 |
| 10 #include "lib/error.h" | 10 #include "lib/error.h" |
| 11 #include "vm/ast_printer.h" | 11 #include "vm/ast_printer.h" |
| 12 #include "vm/dart_entry.h" | 12 #include "vm/dart_entry.h" |
| 13 #include "vm/ic_data.h" |
| 13 #include "vm/longjump.h" | 14 #include "vm/longjump.h" |
| 14 #include "vm/object.h" | 15 #include "vm/object.h" |
| 15 #include "vm/object_store.h" | 16 #include "vm/object_store.h" |
| 16 #include "vm/parser.h" | 17 #include "vm/parser.h" |
| 17 #include "vm/resolver.h" | 18 #include "vm/resolver.h" |
| 18 #include "vm/stub_code.h" | 19 #include "vm/stub_code.h" |
| 19 | 20 |
| 20 namespace dart { | 21 namespace dart { |
| 21 | 22 |
| 22 DEFINE_FLAG(bool, print_ast, false, "Print abstract syntax tree."); | 23 DEFINE_FLAG(bool, print_ast, false, "Print abstract syntax tree."); |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 CodeGeneratorState codegen_state(this); | 250 CodeGeneratorState codegen_state(this); |
| 250 if (FLAG_print_scopes && FLAG_print_ast) { | 251 if (FLAG_print_scopes && FLAG_print_ast) { |
| 251 // Print the function scope before code generation. | 252 // Print the function scope before code generation. |
| 252 AstPrinter::PrintFunctionScope(parsed_function_); | 253 AstPrinter::PrintFunctionScope(parsed_function_); |
| 253 } | 254 } |
| 254 if (FLAG_print_ast) { | 255 if (FLAG_print_ast) { |
| 255 // Print the function ast before code generation. | 256 // Print the function ast before code generation. |
| 256 AstPrinter::PrintFunctionNodes(parsed_function_); | 257 AstPrinter::PrintFunctionNodes(parsed_function_); |
| 257 } | 258 } |
| 258 if (FLAG_trace_functions) { | 259 if (FLAG_trace_functions) { |
| 259 // Preserve ECX (function name or object) and EDX (arguments descriptor). | 260 // Preserve ECX (ic-data array or object) and EDX (arguments descriptor). |
| 260 __ pushl(ECX); | 261 __ pushl(ECX); |
| 261 __ pushl(EDX); | 262 __ pushl(EDX); |
| 262 const Function& function = | 263 const Function& function = |
| 263 Function::ZoneHandle(parsed_function_.function().raw()); | 264 Function::ZoneHandle(parsed_function_.function().raw()); |
| 264 __ LoadObject(EAX, function); | 265 __ LoadObject(EAX, function); |
| 265 __ pushl(EAX); | 266 __ pushl(EAX); |
| 266 GenerateCallRuntime(0, kTraceFunctionEntryRuntimeEntry); | 267 GenerateCallRuntime(0, kTraceFunctionEntryRuntimeEntry); |
| 267 __ popl(EAX); | 268 __ popl(EAX); |
| 268 __ popl(EDX); | 269 __ popl(EDX); |
| 269 __ popl(ECX); | 270 __ popl(ECX); |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 | 468 |
| 468 void CodeGenerator::GenerateInstanceCall( | 469 void CodeGenerator::GenerateInstanceCall( |
| 469 intptr_t node_id, | 470 intptr_t node_id, |
| 470 intptr_t token_index, | 471 intptr_t token_index, |
| 471 const String& function_name, | 472 const String& function_name, |
| 472 int num_arguments, | 473 int num_arguments, |
| 473 const Array& optional_arguments_names) { | 474 const Array& optional_arguments_names) { |
| 474 // Set up the function name and number of arguments (including the receiver) | 475 // Set up the function name and number of arguments (including the receiver) |
| 475 // to the InstanceCall stub which will resolve the correct entrypoint for | 476 // to the InstanceCall stub which will resolve the correct entrypoint for |
| 476 // the operator and call it. | 477 // the operator and call it. |
| 477 __ LoadObject(ECX, function_name); | 478 ICData ic_data(function_name, 1); |
| 479 __ LoadObject(ECX, Array::ZoneHandle(ic_data.data())); |
| 478 __ LoadObject(EDX, ArgumentsDescriptor(num_arguments, | 480 __ LoadObject(EDX, ArgumentsDescriptor(num_arguments, |
| 479 optional_arguments_names)); | 481 optional_arguments_names)); |
| 480 __ call(&StubCode::CallInstanceFunctionLabel()); | 482 __ call(&StubCode::CallInstanceFunctionLabel()); |
| 481 AddCurrentDescriptor(PcDescriptors::kIcCall, | 483 AddCurrentDescriptor(PcDescriptors::kIcCall, |
| 482 node_id, | 484 node_id, |
| 483 token_index); | 485 token_index); |
| 484 __ addl(ESP, Immediate(num_arguments * kWordSize)); | 486 __ addl(ESP, Immediate(num_arguments * kWordSize)); |
| 485 } | 487 } |
| 486 | 488 |
| 487 | 489 |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 Label all_arguments_processed; | 693 Label all_arguments_processed; |
| 692 __ cmpl(Address(EDI, 0), raw_null); | 694 __ cmpl(Address(EDI, 0), raw_null); |
| 693 __ j(EQUAL, &all_arguments_processed, Assembler::kNearJump); | 695 __ j(EQUAL, &all_arguments_processed, Assembler::kNearJump); |
| 694 | 696 |
| 695 __ Bind(&wrong_num_arguments); | 697 __ Bind(&wrong_num_arguments); |
| 696 if (function.IsClosureFunction()) { | 698 if (function.IsClosureFunction()) { |
| 697 GenerateCallRuntime(function.token_index(), | 699 GenerateCallRuntime(function.token_index(), |
| 698 kClosureArgumentMismatchRuntimeEntry); | 700 kClosureArgumentMismatchRuntimeEntry); |
| 699 } else { | 701 } else { |
| 700 // Invoke noSuchMethod function. | 702 // Invoke noSuchMethod function. |
| 701 __ LoadObject(ECX, String::ZoneHandle(function.name())); | 703 ICData ic_data(String::Handle(function.name()), 1); |
| 704 __ LoadObject(ECX, Array::ZoneHandle(ic_data.data())); |
| 702 // EBP : points to previous frame pointer. | 705 // EBP : points to previous frame pointer. |
| 703 // EBP + 4 : points to return address. | 706 // EBP + 4 : points to return address. |
| 704 // EBP + 8 : address of last argument (arg n-1). | 707 // EBP + 8 : address of last argument (arg n-1). |
| 705 // ESP + 8 + 4*(n-1) : address of first argument (arg 0). | 708 // ESP + 8 + 4*(n-1) : address of first argument (arg 0). |
| 706 // ECX : function name. | 709 // ECX : ic-data array. |
| 707 // EDX : arguments descriptor array. | 710 // EDX : arguments descriptor array. |
| 708 __ call(&StubCode::CallNoSuchMethodFunctionLabel()); | 711 __ call(&StubCode::CallNoSuchMethodFunctionLabel()); |
| 709 } | 712 } |
| 710 | 713 |
| 711 if (FLAG_trace_functions) { | 714 if (FLAG_trace_functions) { |
| 712 __ pushl(EAX); // Preserve result. | 715 __ pushl(EAX); // Preserve result. |
| 713 __ PushObject(function); | 716 __ PushObject(function); |
| 714 GenerateCallRuntime(0, kTraceFunctionExitRuntimeEntry); | 717 GenerateCallRuntime(0, kTraceFunctionExitRuntimeEntry); |
| 715 __ popl(EAX); // Remove argument. | 718 __ popl(EAX); // Remove argument. |
| 716 __ popl(EAX); // Restore result. | 719 __ popl(EAX); // Restore result. |
| (...skipping 1904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2621 const Class& cls = Class::Handle(parsed_function_.function().owner()); | 2624 const Class& cls = Class::Handle(parsed_function_.function().owner()); |
| 2622 const Script& script = Script::Handle(cls.script()); | 2625 const Script& script = Script::Handle(cls.script()); |
| 2623 Parser::ReportMsg(script, token_index, "Error", error_msg, format, args); | 2626 Parser::ReportMsg(script, token_index, "Error", error_msg, format, args); |
| 2624 Isolate::Current()->long_jump_base()->Jump(1, error_msg); | 2627 Isolate::Current()->long_jump_base()->Jump(1, error_msg); |
| 2625 UNREACHABLE(); | 2628 UNREACHABLE(); |
| 2626 } | 2629 } |
| 2627 | 2630 |
| 2628 } // namespace dart | 2631 } // namespace dart |
| 2629 | 2632 |
| 2630 #endif // defined TARGET_ARCH_IA32 | 2633 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |