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

Side by Side Diff: src/arm/virtual-frame-arm.h

Issue 2452002: ARM: Track Smis on top 4 stack positions and Smi loop variables.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 6 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
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 } 147 }
148 148
149 // Add extra in-memory elements to the top of the frame to match an actual 149 // Add extra in-memory elements to the top of the frame to match an actual
150 // frame (eg, the frame after an exception handler is pushed). No code is 150 // frame (eg, the frame after an exception handler is pushed). No code is
151 // emitted. 151 // emitted.
152 void Adjust(int count); 152 void Adjust(int count);
153 153
154 // Forget elements from the top of the frame to match an actual frame (eg, 154 // Forget elements from the top of the frame to match an actual frame (eg,
155 // the frame after a runtime call). No code is emitted except to bring the 155 // the frame after a runtime call). No code is emitted except to bring the
156 // frame to a spilled state. 156 // frame to a spilled state.
157 void Forget(int count) { 157 void Forget(int count);
158 SpillAll();
159 element_count_ -= count;
160 }
161 158
162 // Spill all values from the frame to memory. 159 // Spill all values from the frame to memory.
163 void SpillAll(); 160 void SpillAll();
164 161
165 void AssertIsSpilled() const { 162 void AssertIsSpilled() const {
166 ASSERT(top_of_stack_state_ == NO_TOS_REGISTERS); 163 ASSERT(top_of_stack_state_ == NO_TOS_REGISTERS);
167 ASSERT(register_allocation_map_ == 0); 164 ASSERT(register_allocation_map_ == 0);
168 } 165 }
169 166
170 void AssertIsNotSpilled() { 167 void AssertIsNotSpilled() {
171 ASSERT(!SpilledScope::is_spilled()); 168 ASSERT(!SpilledScope::is_spilled());
172 } 169 }
173 170
174 // Spill all occurrences of a specific register from the frame. 171 // Spill all occurrences of a specific register from the frame.
175 void Spill(Register reg) { 172 void Spill(Register reg) {
176 UNIMPLEMENTED(); 173 UNIMPLEMENTED();
177 } 174 }
178 175
179 // Spill all occurrences of an arbitrary register if possible. Return the 176 // Spill all occurrences of an arbitrary register if possible. Return the
180 // register spilled or no_reg if it was not possible to free any register 177 // register spilled or no_reg if it was not possible to free any register
181 // (ie, they all have frame-external references). Unimplemented. 178 // (ie, they all have frame-external references). Unimplemented.
182 Register SpillAnyRegister(); 179 Register SpillAnyRegister();
183 180
184 // Make this virtual frame have a state identical to an expected virtual 181 // Make this virtual frame have a state identical to an expected virtual
185 // frame. As a side effect, code may be emitted to make this frame match 182 // frame. As a side effect, code may be emitted to make this frame match
186 // the expected one. 183 // the expected one.
184 void MergeTo(VirtualFrame* expected, Condition cond = al);
187 void MergeTo(const VirtualFrame* expected, Condition cond = al); 185 void MergeTo(const VirtualFrame* expected, Condition cond = al);
188 186
187 // Checks whether this frame can be branched to by the other frame.
188 bool IsCompatibleWith(const VirtualFrame* other) const {
189 return (tos_known_smi_map_ & (~other->tos_known_smi_map_)) == 0;
190 }
191
189 // Detach a frame from its code generator, perhaps temporarily. This 192 // Detach a frame from its code generator, perhaps temporarily. This
190 // tells the register allocator that it is free to use frame-internal 193 // tells the register allocator that it is free to use frame-internal
191 // registers. Used when the code generator's frame is switched from this 194 // registers. Used when the code generator's frame is switched from this
192 // one to NULL by an unconditional jump. 195 // one to NULL by an unconditional jump.
193 void DetachFromCodeGenerator() { 196 void DetachFromCodeGenerator() {
194 AssertIsSpilled(); 197 AssertIsSpilled();
195 } 198 }
196 199
197 // (Re)attach a frame to its code generator. This informs the register 200 // (Re)attach a frame to its code generator. This informs the register
198 // allocator that the frame-internal register references are active again. 201 // allocator that the frame-internal register references are active again.
(...skipping 28 matching lines...) Expand all
227 return MemOperand(sp, 0); 230 return MemOperand(sp, 0);
228 } 231 }
229 232
230 // An element of the expression stack as an assembly operand. 233 // An element of the expression stack as an assembly operand.
231 MemOperand ElementAt(int index) { 234 MemOperand ElementAt(int index) {
232 int adjusted_index = index - kVirtualElements[top_of_stack_state_]; 235 int adjusted_index = index - kVirtualElements[top_of_stack_state_];
233 ASSERT(adjusted_index >= 0); 236 ASSERT(adjusted_index >= 0);
234 return MemOperand(sp, adjusted_index * kPointerSize); 237 return MemOperand(sp, adjusted_index * kPointerSize);
235 } 238 }
236 239
240 bool KnownSmiAt(int index) {
241 if (index >= kTOSKnownSmiMapSize) return false;
242 return (tos_known_smi_map_ & (1 << index)) != 0;
243 }
244
237 // A frame-allocated local as an assembly operand. 245 // A frame-allocated local as an assembly operand.
238 inline MemOperand LocalAt(int index); 246 inline MemOperand LocalAt(int index);
239 247
240 // Push the address of the receiver slot on the frame. 248 // Push the address of the receiver slot on the frame.
241 void PushReceiverSlotAddress(); 249 void PushReceiverSlotAddress();
242 250
243 // The function frame slot. 251 // The function frame slot.
244 MemOperand Function() { return MemOperand(fp, kFunctionOffset); } 252 MemOperand Function() { return MemOperand(fp, kFunctionOffset); }
245 253
246 // The context frame slot. 254 // The context frame slot.
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 void PopToR1R0(); 353 void PopToR1R0();
346 354
347 // Takes the top element and puts it in r1. 355 // Takes the top element and puts it in r1.
348 void PopToR1(); 356 void PopToR1();
349 357
350 // Takes the top element and puts it in r0. 358 // Takes the top element and puts it in r0.
351 void PopToR0(); 359 void PopToR0();
352 360
353 // Push an element on top of the expression stack and emit a 361 // Push an element on top of the expression stack and emit a
354 // corresponding push instruction. 362 // corresponding push instruction.
355 void EmitPush(Register reg); 363 void EmitPush(Register reg, TypeInfo type_info = TypeInfo::Unknown());
356 void EmitPush(Operand operand); 364 void EmitPush(Operand operand, TypeInfo type_info = TypeInfo::Unknown());
357 void EmitPush(MemOperand operand); 365 void EmitPush(MemOperand operand, TypeInfo type_info = TypeInfo::Unknown());
358 void EmitPushRoot(Heap::RootListIndex index); 366 void EmitPushRoot(Heap::RootListIndex index);
359 367
360 // Overwrite the nth thing on the stack. If the nth position is in a 368 // Overwrite the nth thing on the stack. If the nth position is in a
361 // register then this turns into a mov, otherwise an str. Afterwards 369 // register then this turns into a mov, otherwise an str. Afterwards
362 // you can still use the register even if it is a register that can be 370 // you can still use the register even if it is a register that can be
363 // used for TOS (r0 or r1). 371 // used for TOS (r0 or r1).
364 void SetElementAt(Register reg, int this_far_down); 372 void SetElementAt(Register reg, int this_far_down);
365 373
366 // Get a register which is free and which must be immediately used to 374 // Get a register which is free and which must be immediately used to
367 // push on the top of the stack. 375 // push on the top of the stack.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 420
413 static Register AllocatedRegister(int r) { 421 static Register AllocatedRegister(int r) {
414 ASSERT(r >= 0 && r < kNumberOfAllocatedRegisters); 422 ASSERT(r >= 0 && r < kNumberOfAllocatedRegisters);
415 return kAllocatedRegisters[r]; 423 return kAllocatedRegisters[r];
416 } 424 }
417 425
418 // The number of elements on the stack frame. 426 // The number of elements on the stack frame.
419 int element_count_; 427 int element_count_;
420 TopOfStack top_of_stack_state_:3; 428 TopOfStack top_of_stack_state_:3;
421 int register_allocation_map_:kNumberOfAllocatedRegisters; 429 int register_allocation_map_:kNumberOfAllocatedRegisters;
430 static const int kTOSKnownSmiMapSize = 4;
431 unsigned tos_known_smi_map_:kTOSKnownSmiMapSize;
422 432
423 // The index of the element that is at the processor's stack pointer 433 // The index of the element that is at the processor's stack pointer
424 // (the sp register). For now since everything is in memory it is given 434 // (the sp register). For now since everything is in memory it is given
425 // by the number of elements on the not-very-virtual stack frame. 435 // by the number of elements on the not-very-virtual stack frame.
426 int stack_pointer() { return element_count_ - 1; } 436 int stack_pointer() { return element_count_ - 1; }
427 437
428 // The number of frame-allocated locals and parameters respectively. 438 // The number of frame-allocated locals and parameters respectively.
429 inline int parameter_count() const; 439 inline int parameter_count() const;
430 inline int local_count() const; 440 inline int local_count() const;
431 441
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 // If all top-of-stack registers are in use then the lowest one is pushed 476 // If all top-of-stack registers are in use then the lowest one is pushed
467 // onto the physical stack and made free. 477 // onto the physical stack and made free.
468 void EnsureOneFreeTOSRegister(); 478 void EnsureOneFreeTOSRegister();
469 479
470 // Emit instructions to get the top of stack state from where we are to where 480 // Emit instructions to get the top of stack state from where we are to where
471 // we want to be. 481 // we want to be.
472 void MergeTOSTo(TopOfStack expected_state, Condition cond = al); 482 void MergeTOSTo(TopOfStack expected_state, Condition cond = al);
473 483
474 inline bool Equals(const VirtualFrame* other); 484 inline bool Equals(const VirtualFrame* other);
475 485
486 inline void LowerHeight(int count) {
487 element_count_ -= count;
488 if (count >= kTOSKnownSmiMapSize) {
489 tos_known_smi_map_ = 0;
490 } else {
491 tos_known_smi_map_ >>= count;
492 }
493 }
494
495 inline void RaiseHeight(int count, unsigned known_smi_map = 0) {
496 ASSERT(known_smi_map < (1u << count));
497 element_count_ += count;
498 if (count >= kTOSKnownSmiMapSize) {
499 tos_known_smi_map_ = known_smi_map;
500 } else {
501 tos_known_smi_map_ = ((tos_known_smi_map_ << count) | known_smi_map);
502 }
503 }
504
476 friend class JumpTarget; 505 friend class JumpTarget;
477 }; 506 };
478 507
479 508
480 } } // namespace v8::internal 509 } } // namespace v8::internal
481 510
482 #endif // V8_ARM_VIRTUAL_FRAME_ARM_H_ 511 #endif // V8_ARM_VIRTUAL_FRAME_ARM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698