| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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/class_finalizer.h" | 12 #include "vm/class_finalizer.h" |
| 13 #include "vm/dart_entry.h" | 13 #include "vm/dart_entry.h" |
| 14 #include "vm/debugger.h" | 14 #include "vm/debugger.h" |
| 15 #include "vm/ic_data.h" | |
| 16 #include "vm/longjump.h" | 15 #include "vm/longjump.h" |
| 17 #include "vm/object.h" | 16 #include "vm/object.h" |
| 18 #include "vm/object_store.h" | 17 #include "vm/object_store.h" |
| 19 #include "vm/parser.h" | 18 #include "vm/parser.h" |
| 20 #include "vm/resolver.h" | 19 #include "vm/resolver.h" |
| 21 #include "vm/stub_code.h" | 20 #include "vm/stub_code.h" |
| 22 | 21 |
| 23 namespace dart { | 22 namespace dart { |
| 24 | 23 |
| 25 DEFINE_FLAG(bool, print_ast, false, "Print abstract syntax tree."); | 24 DEFINE_FLAG(bool, print_ast, false, "Print abstract syntax tree."); |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 const Array& optional_arguments_names, | 441 const Array& optional_arguments_names, |
| 443 intptr_t num_args_checked) { | 442 intptr_t num_args_checked) { |
| 444 if (FLAG_print_ic_in_optimized && IsOptimizing()) { | 443 if (FLAG_print_ic_in_optimized && IsOptimizing()) { |
| 445 OS::Print("Generate IC in optimized code: id %d name: '%s'\n", | 444 OS::Print("Generate IC in optimized code: id %d name: '%s'\n", |
| 446 node_id, function_name.ToCString()); | 445 node_id, function_name.ToCString()); |
| 447 } | 446 } |
| 448 ASSERT(num_args_checked > 0); // At least receiver check is necessary. | 447 ASSERT(num_args_checked > 0); // At least receiver check is necessary. |
| 449 // Set up the function name and number of arguments (including the receiver) | 448 // Set up the function name and number of arguments (including the receiver) |
| 450 // to the InstanceCall stub which will resolve the correct entrypoint for | 449 // to the InstanceCall stub which will resolve the correct entrypoint for |
| 451 // the operator and call it. | 450 // the operator and call it. |
| 452 ICData ic_data(function_name, num_args_checked); | 451 ICData& ic_data = ICData::ZoneHandle(); |
| 453 ASSERT(ic_data.NumberOfArgumentsChecked() == num_args_checked); | 452 ic_data = ICData::New(parsed_function().function(), |
| 454 __ LoadObject(ECX, Array::ZoneHandle(ic_data.data())); | 453 function_name, |
| 454 node_id, |
| 455 num_args_checked); |
| 456 __ LoadObject(ECX, ic_data); |
| 455 __ LoadObject(EDX, ArgumentsDescriptor(num_arguments, | 457 __ LoadObject(EDX, ArgumentsDescriptor(num_arguments, |
| 456 optional_arguments_names)); | 458 optional_arguments_names)); |
| 457 uword label_address = 0; | 459 uword label_address = 0; |
| 458 switch (num_args_checked) { | 460 switch (num_args_checked) { |
| 459 case 1: | 461 case 1: |
| 460 label_address = StubCode::OneArgCheckInlineCacheEntryPoint(); | 462 label_address = StubCode::OneArgCheckInlineCacheEntryPoint(); |
| 461 break; | 463 break; |
| 462 case 2: | 464 case 2: |
| 463 label_address = StubCode::TwoArgsCheckInlineCacheEntryPoint(); | 465 label_address = StubCode::TwoArgsCheckInlineCacheEntryPoint(); |
| 464 break; | 466 break; |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 __ cmpl(Address(EDI, 0), raw_null); | 685 __ cmpl(Address(EDI, 0), raw_null); |
| 684 __ j(EQUAL, &all_arguments_processed, Assembler::kNearJump); | 686 __ j(EQUAL, &all_arguments_processed, Assembler::kNearJump); |
| 685 | 687 |
| 686 __ Bind(&wrong_num_arguments); | 688 __ Bind(&wrong_num_arguments); |
| 687 if (function.IsClosureFunction()) { | 689 if (function.IsClosureFunction()) { |
| 688 GenerateCallRuntime(AstNode::kNoId, | 690 GenerateCallRuntime(AstNode::kNoId, |
| 689 0, | 691 0, |
| 690 kClosureArgumentMismatchRuntimeEntry); | 692 kClosureArgumentMismatchRuntimeEntry); |
| 691 } else { | 693 } else { |
| 692 // Invoke noSuchMethod function. | 694 // Invoke noSuchMethod function. |
| 693 ICData ic_data(String::Handle(function.name()), 1); | 695 const int kNumArgsChecked = 1; |
| 694 __ LoadObject(ECX, Array::ZoneHandle(ic_data.data())); | 696 ICData& ic_data = ICData::ZoneHandle(); |
| 697 ic_data = ICData::New(parsed_function().function(), |
| 698 String::Handle(function.name()), |
| 699 AstNode::kNoId, |
| 700 kNumArgsChecked); |
| 701 __ LoadObject(ECX, ic_data); |
| 695 // EBP : points to previous frame pointer. | 702 // EBP : points to previous frame pointer. |
| 696 // EBP + 4 : points to return address. | 703 // EBP + 4 : points to return address. |
| 697 // EBP + 8 : address of last argument (arg n-1). | 704 // EBP + 8 : address of last argument (arg n-1). |
| 698 // ESP + 8 + 4*(n-1) : address of first argument (arg 0). | 705 // ESP + 8 + 4*(n-1) : address of first argument (arg 0). |
| 699 // ECX : ic-data array. | 706 // ECX : ic-data. |
| 700 // EDX : arguments descriptor array. | 707 // EDX : arguments descriptor array. |
| 701 __ call(&StubCode::CallNoSuchMethodFunctionLabel()); | 708 __ call(&StubCode::CallNoSuchMethodFunctionLabel()); |
| 702 } | 709 } |
| 703 | 710 |
| 704 if (FLAG_trace_functions) { | 711 if (FLAG_trace_functions) { |
| 705 __ pushl(EAX); // Preserve result. | 712 __ pushl(EAX); // Preserve result. |
| 706 __ PushObject(Function::ZoneHandle(function.raw())); | 713 __ PushObject(Function::ZoneHandle(function.raw())); |
| 707 GenerateCallRuntime(AstNode::kNoId, | 714 GenerateCallRuntime(AstNode::kNoId, |
| 708 0, | 715 0, |
| 709 kTraceFunctionExitRuntimeEntry); | 716 kTraceFunctionExitRuntimeEntry); |
| (...skipping 2098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2808 const Error& error = Error::Handle( | 2815 const Error& error = Error::Handle( |
| 2809 Parser::FormatError(script, token_index, "Error", format, args)); | 2816 Parser::FormatError(script, token_index, "Error", format, args)); |
| 2810 va_end(args); | 2817 va_end(args); |
| 2811 Isolate::Current()->long_jump_base()->Jump(1, error); | 2818 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 2812 UNREACHABLE(); | 2819 UNREACHABLE(); |
| 2813 } | 2820 } |
| 2814 | 2821 |
| 2815 } // namespace dart | 2822 } // namespace dart |
| 2816 | 2823 |
| 2817 #endif // defined TARGET_ARCH_IA32 | 2824 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |