Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(179)

Side by Side Diff: runtime/vm/intermediate_language_ia32.cc

Issue 12049039: Fix source position for stack traces with optimized top function. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: rebase Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/intermediate_language.cc ('k') | runtime/vm/intermediate_language_x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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/intermediate_language.h" 8 #include "vm/intermediate_language.h"
9 9
10 #include "lib/error.h" 10 #include "lib/error.h"
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 LocationSummary* locs = 178 LocationSummary* locs =
179 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); 179 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall);
180 locs->set_in(0, Location::RegisterLocation(EAX)); 180 locs->set_in(0, Location::RegisterLocation(EAX));
181 locs->set_out(Location::RegisterLocation(EAX)); 181 locs->set_out(Location::RegisterLocation(EAX));
182 return locs; 182 return locs;
183 } 183 }
184 184
185 185
186 static void EmitAssertBoolean(Register reg, 186 static void EmitAssertBoolean(Register reg,
187 intptr_t token_pos, 187 intptr_t token_pos,
188 intptr_t deopt_id,
188 LocationSummary* locs, 189 LocationSummary* locs,
189 FlowGraphCompiler* compiler) { 190 FlowGraphCompiler* compiler) {
190 // Check that the type of the value is allowed in conditional context. 191 // Check that the type of the value is allowed in conditional context.
191 // Call the runtime if the object is not bool::true or bool::false. 192 // Call the runtime if the object is not bool::true or bool::false.
192 ASSERT(locs->always_calls()); 193 ASSERT(locs->always_calls());
193 Label done; 194 Label done;
194 __ CompareObject(reg, Bool::True()); 195 __ CompareObject(reg, Bool::True());
195 __ j(EQUAL, &done, Assembler::kNearJump); 196 __ j(EQUAL, &done, Assembler::kNearJump);
196 __ CompareObject(reg, Bool::False()); 197 __ CompareObject(reg, Bool::False());
197 __ j(EQUAL, &done, Assembler::kNearJump); 198 __ j(EQUAL, &done, Assembler::kNearJump);
198 199
199 __ pushl(reg); // Push the source object. 200 __ pushl(reg); // Push the source object.
200 compiler->GenerateCallRuntime(token_pos, 201 compiler->GenerateCallRuntime(token_pos,
202 deopt_id,
201 kConditionTypeErrorRuntimeEntry, 203 kConditionTypeErrorRuntimeEntry,
202 locs); 204 locs);
203 // We should never return here. 205 // We should never return here.
204 __ int3(); 206 __ int3();
205 __ Bind(&done); 207 __ Bind(&done);
206 } 208 }
207 209
208 210
209 void AssertBooleanInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 211 void AssertBooleanInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
210 Register obj = locs()->in(0).reg(); 212 Register obj = locs()->in(0).reg();
211 Register result = locs()->out().reg(); 213 Register result = locs()->out().reg();
212 214
213 if (!is_eliminated()) { 215 if (!is_eliminated()) {
214 EmitAssertBoolean(obj, token_pos(), locs(), compiler); 216 EmitAssertBoolean(obj, token_pos(), deopt_id(), locs(), compiler);
215 } 217 }
216 ASSERT(obj == result); 218 ASSERT(obj == result);
217 } 219 }
218 220
219 221
220 LocationSummary* ArgumentDefinitionTestInstr::MakeLocationSummary() const { 222 LocationSummary* ArgumentDefinitionTestInstr::MakeLocationSummary() const {
221 const intptr_t kNumInputs = 1; 223 const intptr_t kNumInputs = 1;
222 const intptr_t kNumTemps = 0; 224 const intptr_t kNumTemps = 0;
223 LocationSummary* locs = 225 LocationSummary* locs =
224 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); 226 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall);
225 locs->set_in(0, Location::RegisterLocation(EAX)); 227 locs->set_in(0, Location::RegisterLocation(EAX));
226 locs->set_out(Location::RegisterLocation(EAX)); 228 locs->set_out(Location::RegisterLocation(EAX));
227 return locs; 229 return locs;
228 } 230 }
229 231
230 232
231 void ArgumentDefinitionTestInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 233 void ArgumentDefinitionTestInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
232 Register saved_args_desc = locs()->in(0).reg(); 234 Register saved_args_desc = locs()->in(0).reg();
233 Register result = locs()->out().reg(); 235 Register result = locs()->out().reg();
234 236
235 // Push the result place holder initialized to NULL. 237 // Push the result place holder initialized to NULL.
236 __ PushObject(Object::ZoneHandle()); 238 __ PushObject(Object::ZoneHandle());
237 __ pushl(Immediate(Smi::RawValue(formal_parameter_index()))); 239 __ pushl(Immediate(Smi::RawValue(formal_parameter_index())));
238 __ PushObject(formal_parameter_name()); 240 __ PushObject(formal_parameter_name());
239 __ pushl(saved_args_desc); 241 __ pushl(saved_args_desc);
240 compiler->GenerateCallRuntime(token_pos(), 242 compiler->GenerateCallRuntime(token_pos(),
243 deopt_id(),
241 kArgumentDefinitionTestRuntimeEntry, 244 kArgumentDefinitionTestRuntimeEntry,
242 locs()); 245 locs());
243 __ Drop(3); 246 __ Drop(3);
244 __ popl(result); // Pop bool result. 247 __ popl(result); // Pop bool result.
245 } 248 }
246 249
247 250
248 static Condition TokenKindToSmiCondition(Token::Kind kind) { 251 static Condition TokenKindToSmiCondition(Token::Kind kind) {
249 switch (kind) { 252 switch (kind) {
250 case Token::kEQ: return EQUAL; 253 case Token::kEQ: return EQUAL;
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 __ CompareObject(EAX, Bool::True()); 494 __ CompareObject(EAX, Bool::True());
492 __ j(EQUAL, &false_label, Assembler::kNearJump); 495 __ j(EQUAL, &false_label, Assembler::kNearJump);
493 __ LoadObject(EAX, Bool::True()); 496 __ LoadObject(EAX, Bool::True());
494 __ jmp(&done); 497 __ jmp(&done);
495 __ Bind(&false_label); 498 __ Bind(&false_label);
496 __ LoadObject(EAX, Bool::False()); 499 __ LoadObject(EAX, Bool::False());
497 __ jmp(&done); 500 __ jmp(&done);
498 } 501 }
499 } else { 502 } else {
500 if (branch->is_checked()) { 503 if (branch->is_checked()) {
501 EmitAssertBoolean(EAX, token_pos, locs, compiler); 504 EmitAssertBoolean(EAX, token_pos, deopt_id, locs, compiler);
502 } 505 }
503 __ CompareObject(EAX, Bool::True()); 506 __ CompareObject(EAX, Bool::True());
504 branch->EmitBranchOnCondition(compiler, cond); 507 branch->EmitBranchOnCondition(compiler, cond);
505 } 508 }
506 } 509 }
507 __ jmp(&done); 510 __ jmp(&done);
508 __ Bind(&next_test); 511 __ Bind(&next_test);
509 } 512 }
510 // Fall through leads to deoptimization 513 // Fall through leads to deoptimization
511 __ jmp(deopt); 514 __ jmp(deopt);
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 Register right = locs()->in(1).reg(); 865 Register right = locs()->in(1).reg();
863 __ pushl(left); 866 __ pushl(left);
864 __ pushl(right); 867 __ pushl(right);
865 EmitEqualityAsInstanceCall(compiler, 868 EmitEqualityAsInstanceCall(compiler,
866 deopt_id(), 869 deopt_id(),
867 token_pos(), 870 token_pos(),
868 Token::kEQ, // kNE reverse occurs at branch. 871 Token::kEQ, // kNE reverse occurs at branch.
869 locs(), 872 locs(),
870 *ic_data()); 873 *ic_data());
871 if (branch->is_checked()) { 874 if (branch->is_checked()) {
872 EmitAssertBoolean(EAX, token_pos(), locs(), compiler); 875 EmitAssertBoolean(EAX, token_pos(), deopt_id(), locs(), compiler);
873 } 876 }
874 Condition branch_condition = (kind() == Token::kNE) ? NOT_EQUAL : EQUAL; 877 Condition branch_condition = (kind() == Token::kNE) ? NOT_EQUAL : EQUAL;
875 __ CompareObject(EAX, Bool::True()); 878 __ CompareObject(EAX, Bool::True());
876 branch->EmitBranchOnCondition(compiler, branch_condition); 879 branch->EmitBranchOnCondition(compiler, branch_condition);
877 } 880 }
878 881
879 882
880 LocationSummary* RelationalOpInstr::MakeLocationSummary() const { 883 LocationSummary* RelationalOpInstr::MakeLocationSummary() const {
881 const intptr_t kNumInputs = 2; 884 const intptr_t kNumInputs = 2;
882 const intptr_t kNumTemps = 0; 885 const intptr_t kNumTemps = 0;
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after
1516 return summary; 1519 return summary;
1517 } 1520 }
1518 1521
1519 1522
1520 void InstanceOfInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 1523 void InstanceOfInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
1521 ASSERT(locs()->in(0).reg() == EAX); // Value. 1524 ASSERT(locs()->in(0).reg() == EAX); // Value.
1522 ASSERT(locs()->in(1).reg() == ECX); // Instantiator. 1525 ASSERT(locs()->in(1).reg() == ECX); // Instantiator.
1523 ASSERT(locs()->in(2).reg() == EDX); // Instantiator type arguments. 1526 ASSERT(locs()->in(2).reg() == EDX); // Instantiator type arguments.
1524 1527
1525 compiler->GenerateInstanceOf(token_pos(), 1528 compiler->GenerateInstanceOf(token_pos(),
1529 deopt_id(),
1526 type(), 1530 type(),
1527 negate_result(), 1531 negate_result(),
1528 locs()); 1532 locs());
1529 ASSERT(locs()->out().reg() == EAX); 1533 ASSERT(locs()->out().reg() == EAX);
1530 } 1534 }
1531 1535
1532 1536
1533 LocationSummary* CreateArrayInstr::MakeLocationSummary() const { 1537 LocationSummary* CreateArrayInstr::MakeLocationSummary() const {
1534 const intptr_t kNumInputs = 1; 1538 const intptr_t kNumInputs = 1;
1535 const intptr_t kNumTemps = 0; 1539 const intptr_t kNumTemps = 0;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1578 Register type_arguments = locs()->in(0).reg(); 1582 Register type_arguments = locs()->in(0).reg();
1579 Register instantiator_type_arguments = locs()->in(1).reg(); 1583 Register instantiator_type_arguments = locs()->in(1).reg();
1580 Register result = locs()->out().reg(); 1584 Register result = locs()->out().reg();
1581 1585
1582 // Push the result place holder initialized to NULL. 1586 // Push the result place holder initialized to NULL.
1583 __ PushObject(Object::ZoneHandle()); 1587 __ PushObject(Object::ZoneHandle());
1584 __ PushObject(cls); 1588 __ PushObject(cls);
1585 __ pushl(type_arguments); 1589 __ pushl(type_arguments);
1586 __ pushl(instantiator_type_arguments); 1590 __ pushl(instantiator_type_arguments);
1587 compiler->GenerateCallRuntime(token_pos(), 1591 compiler->GenerateCallRuntime(token_pos(),
1592 deopt_id(),
1588 kAllocateObjectWithBoundsCheckRuntimeEntry, 1593 kAllocateObjectWithBoundsCheckRuntimeEntry,
1589 locs()); 1594 locs());
1590 // Pop instantiator type arguments, type arguments, and class. 1595 // Pop instantiator type arguments, type arguments, and class.
1591 // source location. 1596 // source location.
1592 __ Drop(3); 1597 __ Drop(3);
1593 __ popl(result); // Pop new instance. 1598 __ popl(result); // Pop new instance.
1594 } 1599 }
1595 1600
1596 1601
1597 LocationSummary* LoadFieldInstr::MakeLocationSummary() const { 1602 LocationSummary* LoadFieldInstr::MakeLocationSummary() const {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1653 __ cmpl(FieldAddress(instantiator_reg, TypeArguments::length_offset()), 1658 __ cmpl(FieldAddress(instantiator_reg, TypeArguments::length_offset()),
1654 Immediate(Smi::RawValue(len))); 1659 Immediate(Smi::RawValue(len)));
1655 __ j(EQUAL, &type_arguments_instantiated, Assembler::kNearJump); 1660 __ j(EQUAL, &type_arguments_instantiated, Assembler::kNearJump);
1656 __ Bind(&type_arguments_uninstantiated); 1661 __ Bind(&type_arguments_uninstantiated);
1657 } 1662 }
1658 // A runtime call to instantiate the type arguments is required. 1663 // A runtime call to instantiate the type arguments is required.
1659 __ PushObject(Object::ZoneHandle()); // Make room for the result. 1664 __ PushObject(Object::ZoneHandle()); // Make room for the result.
1660 __ PushObject(type_arguments()); 1665 __ PushObject(type_arguments());
1661 __ pushl(instantiator_reg); // Push instantiator type arguments. 1666 __ pushl(instantiator_reg); // Push instantiator type arguments.
1662 compiler->GenerateCallRuntime(token_pos(), 1667 compiler->GenerateCallRuntime(token_pos(),
1668 deopt_id(),
1663 kInstantiateTypeArgumentsRuntimeEntry, 1669 kInstantiateTypeArgumentsRuntimeEntry,
1664 locs()); 1670 locs());
1665 __ Drop(2); // Drop instantiator and uninstantiated type arguments. 1671 __ Drop(2); // Drop instantiator and uninstantiated type arguments.
1666 __ popl(result_reg); // Pop instantiated type arguments. 1672 __ popl(result_reg); // Pop instantiated type arguments.
1667 __ Bind(&type_arguments_instantiated); 1673 __ Bind(&type_arguments_instantiated);
1668 ASSERT(instantiator_reg == result_reg); 1674 ASSERT(instantiator_reg == result_reg);
1669 // 'result_reg': Instantiated type arguments. 1675 // 'result_reg': Instantiated type arguments.
1670 } 1676 }
1671 1677
1672 1678
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
1831 } 1837 }
1832 1838
1833 1839
1834 void CloneContextInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 1840 void CloneContextInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
1835 Register context_value = locs()->in(0).reg(); 1841 Register context_value = locs()->in(0).reg();
1836 Register result = locs()->out().reg(); 1842 Register result = locs()->out().reg();
1837 1843
1838 __ PushObject(Object::ZoneHandle()); // Make room for the result. 1844 __ PushObject(Object::ZoneHandle()); // Make room for the result.
1839 __ pushl(context_value); 1845 __ pushl(context_value);
1840 compiler->GenerateCallRuntime(token_pos(), 1846 compiler->GenerateCallRuntime(token_pos(),
1847 deopt_id(),
1841 kCloneContextRuntimeEntry, 1848 kCloneContextRuntimeEntry,
1842 locs()); 1849 locs());
1843 __ popl(result); // Remove argument. 1850 __ popl(result); // Remove argument.
1844 __ popl(result); // Get result (cloned context). 1851 __ popl(result); // Get result (cloned context).
1845 } 1852 }
1846 1853
1847 1854
1848 LocationSummary* CatchEntryInstr::MakeLocationSummary() const { 1855 LocationSummary* CatchEntryInstr::MakeLocationSummary() const {
1849 return LocationSummary::Make(0, 1856 return LocationSummary::Make(0,
1850 Location::NoLocation(), 1857 Location::NoLocation(),
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1885 1892
1886 class CheckStackOverflowSlowPath : public SlowPathCode { 1893 class CheckStackOverflowSlowPath : public SlowPathCode {
1887 public: 1894 public:
1888 explicit CheckStackOverflowSlowPath(CheckStackOverflowInstr* instruction) 1895 explicit CheckStackOverflowSlowPath(CheckStackOverflowInstr* instruction)
1889 : instruction_(instruction) { } 1896 : instruction_(instruction) { }
1890 1897
1891 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { 1898 virtual void EmitNativeCode(FlowGraphCompiler* compiler) {
1892 __ Comment("CheckStackOverflowSlowPath"); 1899 __ Comment("CheckStackOverflowSlowPath");
1893 __ Bind(entry_label()); 1900 __ Bind(entry_label());
1894 compiler->SaveLiveRegisters(instruction_->locs()); 1901 compiler->SaveLiveRegisters(instruction_->locs());
1902 // pending_deoptimization_env_ is needed to generate a runtime call that
1903 // may throw an exception.
1904 ASSERT(compiler->pending_deoptimization_env_ == NULL);
1905 compiler->pending_deoptimization_env_ = instruction_->env();
1895 compiler->GenerateCallRuntime(instruction_->token_pos(), 1906 compiler->GenerateCallRuntime(instruction_->token_pos(),
1907 instruction_->deopt_id(),
1896 kStackOverflowRuntimeEntry, 1908 kStackOverflowRuntimeEntry,
1897 instruction_->locs()); 1909 instruction_->locs());
1910 compiler->pending_deoptimization_env_ = NULL;
1898 compiler->RestoreLiveRegisters(instruction_->locs()); 1911 compiler->RestoreLiveRegisters(instruction_->locs());
1899 __ jmp(exit_label()); 1912 __ jmp(exit_label());
1900 } 1913 }
1901 1914
1902 private: 1915 private:
1903 CheckStackOverflowInstr* instruction_; 1916 CheckStackOverflowInstr* instruction_;
1904 }; 1917 };
1905 1918
1906 1919
1907 void CheckStackOverflowInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 1920 void CheckStackOverflowInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
(...skipping 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after
3023 3036
3024 3037
3025 LocationSummary* ThrowInstr::MakeLocationSummary() const { 3038 LocationSummary* ThrowInstr::MakeLocationSummary() const {
3026 return new LocationSummary(0, 0, LocationSummary::kCall); 3039 return new LocationSummary(0, 0, LocationSummary::kCall);
3027 } 3040 }
3028 3041
3029 3042
3030 3043
3031 void ThrowInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 3044 void ThrowInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
3032 compiler->GenerateCallRuntime(token_pos(), 3045 compiler->GenerateCallRuntime(token_pos(),
3046 deopt_id(),
3033 kThrowRuntimeEntry, 3047 kThrowRuntimeEntry,
3034 locs()); 3048 locs());
3035 __ int3(); 3049 __ int3();
3036 } 3050 }
3037 3051
3038 3052
3039 LocationSummary* ReThrowInstr::MakeLocationSummary() const { 3053 LocationSummary* ReThrowInstr::MakeLocationSummary() const {
3040 return new LocationSummary(0, 0, LocationSummary::kCall); 3054 return new LocationSummary(0, 0, LocationSummary::kCall);
3041 } 3055 }
3042 3056
3043 3057
3044 void ReThrowInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 3058 void ReThrowInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
3045 compiler->GenerateCallRuntime(token_pos(), 3059 compiler->GenerateCallRuntime(token_pos(),
3060 deopt_id(),
3046 kReThrowRuntimeEntry, 3061 kReThrowRuntimeEntry,
3047 locs()); 3062 locs());
3048 __ int3(); 3063 __ int3();
3049 } 3064 }
3050 3065
3051 3066
3052 LocationSummary* GotoInstr::MakeLocationSummary() const { 3067 LocationSummary* GotoInstr::MakeLocationSummary() const {
3053 return new LocationSummary(0, 0, LocationSummary::kNoCall); 3068 return new LocationSummary(0, 0, LocationSummary::kNoCall);
3054 } 3069 }
3055 3070
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
3331 PcDescriptors::kOther, 3346 PcDescriptors::kOther,
3332 locs()); 3347 locs());
3333 __ Drop(2); // Discard type arguments and receiver. 3348 __ Drop(2); // Discard type arguments and receiver.
3334 } 3349 }
3335 3350
3336 } // namespace dart 3351 } // namespace dart
3337 3352
3338 #undef __ 3353 #undef __
3339 3354
3340 #endif // defined TARGET_ARCH_IA32 3355 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language.cc ('k') | runtime/vm/intermediate_language_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698