| 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" |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 __ nop(5); | 291 __ nop(5); |
| 292 const Function& function = | 292 const Function& function = |
| 293 Function::ZoneHandle(parsed_function_.function().raw()); | 293 Function::ZoneHandle(parsed_function_.function().raw()); |
| 294 __ LoadObject(EAX, function); | 294 __ LoadObject(EAX, function); |
| 295 __ movl(EBX, FieldAddress(EAX, Function::invocation_counter_offset())); | 295 __ movl(EBX, FieldAddress(EAX, Function::invocation_counter_offset())); |
| 296 __ incl(EBX); | 296 __ incl(EBX); |
| 297 if (may_optimize) { | 297 if (may_optimize) { |
| 298 __ cmpl(EBX, Immediate(FLAG_optimization_invocation_threshold)); | 298 __ cmpl(EBX, Immediate(FLAG_optimization_invocation_threshold)); |
| 299 __ j(GREATER, &StubCode::OptimizeInvokedFunctionLabel()); | 299 __ j(GREATER, &StubCode::OptimizeInvokedFunctionLabel()); |
| 300 } | 300 } |
| 301 // EBX is an integer value (not an object). |
| 301 __ movl(FieldAddress(EAX, Function::invocation_counter_offset()), EBX); | 302 __ movl(FieldAddress(EAX, Function::invocation_counter_offset()), EBX); |
| 302 } | 303 } |
| 303 } | 304 } |
| 304 | 305 |
| 305 | 306 |
| 306 // Verify assumptions (in debug mode only). | 307 // Verify assumptions (in debug mode only). |
| 307 // - No two deopt descriptors have the same node id (deoptimization). | 308 // - No two deopt descriptors have the same node id (deoptimization). |
| 308 // - No two ic-call descriptors have the same node id (type feedback). | 309 // - No two ic-call descriptors have the same node id (type feedback). |
| 309 // - No two descriptors of same kind have the same PC. | 310 // - No two descriptors of same kind have the same PC. |
| 310 // A function without unique ids is marked as non-optimizable (e.g., because of | 311 // A function without unique ids is marked as non-optimizable (e.g., because of |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 Register scratch) { | 396 Register scratch) { |
| 396 if (variable.is_captured()) { | 397 if (variable.is_captured()) { |
| 397 // The variable lives in the context. | 398 // The variable lives in the context. |
| 398 int delta = state()->context_level() - variable.owner()->context_level(); | 399 int delta = state()->context_level() - variable.owner()->context_level(); |
| 399 ASSERT(delta >= 0); | 400 ASSERT(delta >= 0); |
| 400 Register base = CTX; | 401 Register base = CTX; |
| 401 while (delta-- > 0) { | 402 while (delta-- > 0) { |
| 402 __ movl(scratch, FieldAddress(base, Context::parent_offset())); | 403 __ movl(scratch, FieldAddress(base, Context::parent_offset())); |
| 403 base = scratch; | 404 base = scratch; |
| 404 } | 405 } |
| 405 __ movl(FieldAddress(base, Context::variable_offset(variable.index())), | 406 __ StoreIntoObject( |
| 406 src); | 407 base, |
| 408 FieldAddress(base, Context::variable_offset(variable.index())), |
| 409 src); |
| 407 } else { | 410 } else { |
| 408 // The variable lives in the current stack frame. | 411 // The variable lives in the current stack frame. |
| 409 __ movl(Address(EBP, variable.index() * kWordSize), src); | 412 __ movl(Address(EBP, variable.index() * kWordSize), src); |
| 410 } | 413 } |
| 411 } | 414 } |
| 412 | 415 |
| 413 | 416 |
| 414 void CodeGenerator::GeneratePushVariable(const LocalVariable& variable, | 417 void CodeGenerator::GeneratePushVariable(const LocalVariable& variable, |
| 415 Register scratch) { | 418 Register scratch) { |
| 416 if (variable.is_captured()) { | 419 if (variable.is_captured()) { |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 928 (scope != NULL) ? scope->num_context_variables() : 0; | 931 (scope != NULL) ? scope->num_context_variables() : 0; |
| 929 if (num_context_variables > 0) { | 932 if (num_context_variables > 0) { |
| 930 // The loop local scope declares variables that are captured. | 933 // The loop local scope declares variables that are captured. |
| 931 // Allocate and chain a new context. | 934 // Allocate and chain a new context. |
| 932 __ movl(EDX, Immediate(num_context_variables)); | 935 __ movl(EDX, Immediate(num_context_variables)); |
| 933 const ExternalLabel label("alloc_context", | 936 const ExternalLabel label("alloc_context", |
| 934 StubCode::AllocateContextEntryPoint()); | 937 StubCode::AllocateContextEntryPoint()); |
| 935 GenerateCall(node_sequence->token_index(), &label); | 938 GenerateCall(node_sequence->token_index(), &label); |
| 936 | 939 |
| 937 // Chain the new context in EAX to its parent in CTX. | 940 // Chain the new context in EAX to its parent in CTX. |
| 938 __ movl(FieldAddress(EAX, Context::parent_offset()), CTX); | 941 __ StoreIntoObject(EAX, FieldAddress(EAX, Context::parent_offset()), CTX); |
| 939 // Set new context as current context. | 942 // Set new context as current context. |
| 940 __ movl(CTX, EAX); | 943 __ movl(CTX, EAX); |
| 941 state()->set_context_level(scope->context_level()); | 944 state()->set_context_level(scope->context_level()); |
| 942 | 945 |
| 943 // If this node_sequence is the body of the function being compiled, copy | 946 // If this node_sequence is the body of the function being compiled, copy |
| 944 // the captured parameters from the frame into the context. | 947 // the captured parameters from the frame into the context. |
| 945 if (node_sequence == parsed_function_.node_sequence()) { | 948 if (node_sequence == parsed_function_.node_sequence()) { |
| 946 ASSERT(scope->context_level() == 1); | 949 ASSERT(scope->context_level() == 1); |
| 947 const Immediate raw_null = | 950 const Immediate raw_null = |
| 948 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 951 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
| (...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1900 const Function& function = | 1903 const Function& function = |
| 1901 Function::ZoneHandle(parsed_function_.function().raw()); | 1904 Function::ZoneHandle(parsed_function_.function().raw()); |
| 1902 __ LoadObject(EAX, function); | 1905 __ LoadObject(EAX, function); |
| 1903 __ movl(EBX, FieldAddress(EAX, Function::invocation_counter_offset())); | 1906 __ movl(EBX, FieldAddress(EAX, Function::invocation_counter_offset())); |
| 1904 __ incl(EBX); | 1907 __ incl(EBX); |
| 1905 if (!FLAG_report_invocation_count) { | 1908 if (!FLAG_report_invocation_count) { |
| 1906 // Prevent overflow. | 1909 // Prevent overflow. |
| 1907 __ cmpl(EBX, Immediate(FLAG_optimization_invocation_threshold)); | 1910 __ cmpl(EBX, Immediate(FLAG_optimization_invocation_threshold)); |
| 1908 __ j(GREATER, &done); | 1911 __ j(GREATER, &done); |
| 1909 } | 1912 } |
| 1913 // EBX is an integer value (not an object). |
| 1910 __ movl(FieldAddress(EAX, Function::invocation_counter_offset()), EBX); | 1914 __ movl(FieldAddress(EAX, Function::invocation_counter_offset()), EBX); |
| 1911 __ Bind(&done); | 1915 __ Bind(&done); |
| 1912 } | 1916 } |
| 1913 | 1917 |
| 1914 | 1918 |
| 1915 void CodeGenerator::VisitWhileNode(WhileNode* node) { | 1919 void CodeGenerator::VisitWhileNode(WhileNode* node) { |
| 1916 const Bool& bool_true = Bool::ZoneHandle(Bool::True()); | 1920 const Bool& bool_true = Bool::ZoneHandle(Bool::True()); |
| 1917 SourceLabel* label = node->label(); | 1921 SourceLabel* label = node->label(); |
| 1918 __ Bind(label->continue_label()); | 1922 __ Bind(label->continue_label()); |
| 1919 node->condition()->Visit(this); | 1923 node->condition()->Visit(this); |
| (...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2797 message_buffer, kMessageBufferSize, | 2801 message_buffer, kMessageBufferSize, |
| 2798 format, args); | 2802 format, args); |
| 2799 va_end(args); | 2803 va_end(args); |
| 2800 Isolate::Current()->long_jump_base()->Jump(1, message_buffer); | 2804 Isolate::Current()->long_jump_base()->Jump(1, message_buffer); |
| 2801 UNREACHABLE(); | 2805 UNREACHABLE(); |
| 2802 } | 2806 } |
| 2803 | 2807 |
| 2804 } // namespace dart | 2808 } // namespace dart |
| 2805 | 2809 |
| 2806 #endif // defined TARGET_ARCH_IA32 | 2810 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |