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

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

Issue 13201: A first stab at using the top of stack as the... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/toiger/
Patch Set: '' Created 12 years 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 | « no previous file | src/virtual-frame-ia32.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 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 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 15 matching lines...) Expand all
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #ifndef V8_VIRTUAL_FRAME_IA32_H_ 28 #ifndef V8_VIRTUAL_FRAME_IA32_H_
29 #define V8_VIRTUAL_FRAME_IA32_H_ 29 #define V8_VIRTUAL_FRAME_IA32_H_
30 30
31 #include "macro-assembler.h" 31 #include "macro-assembler.h"
32 #include "register-allocator.h" 32 #include "register-allocator.h"
33 33
34 namespace v8 { namespace internal { 34 namespace v8 { namespace internal {
35 35
36
37 // The code generator's view of a frame element, when it wants to use it.
38 //
39 // A Result can be a register or a constant.
40 class Result BASE_EMBEDDED {
41 public:
42 // Construct a register Result.
43 explicit Result(Register reg, CodeGenerator* cgen);
44
45 // Construct a Result whose value is a compile-time constant.
46 Result(Handle<Object> value, CodeGenerator * cgen) :
47 type_(CONSTANT),
48 cgen_(cgen) {
49 data_.handle_ = value.location();
50 }
51
52 ~Result() {
53 // We have called Unuse() before Result goes out of scope.
54 ASSERT(reg_.is(no_reg));
55 }
56
57 void Unuse();
58
59 bool is_register() const { return type() == REGISTER; }
60 bool is_constant() const { return type() == CONSTANT; }
61
62 Register reg() const {
63 ASSERT(type() == REGISTER);
64 return data_.reg_;
65 }
66
67 Handle<Object> handle() const {
68 ASSERT(type() == CONSTANT);
69 return Handle<Object>(data_.handle_);
70 }
71
72 private:
73 enum Type { REGISTER, CONSTANT };
74
75 Type type_;
76
77 Type type() const { return type_; }
78
79 union {
80 Register reg_;
81 Object** handle_;
82 } data_;
83
84 CodeGenerator* cgen_;
85 };
86
87
88 // A result in a register just means that the value can be read from the registe r
89
90
36 // ------------------------------------------------------------------------- 91 // -------------------------------------------------------------------------
37 // Virtual frame elements 92 // Virtual frame elements
38 // 93 //
39 // The internal elements of the virtual frames. There are several kinds of 94 // The internal elements of the virtual frames. There are several kinds of
40 // elements: 95 // elements:
41 // * Memory: an element that resides in the actual frame. Its address is 96 // * Memory: an element that resides in the actual frame. Its address is
42 // given by its position in the virtual frame. 97 // given by its position in the virtual frame.
43 // * Register: an element that resides in a register. 98 // * Register: an element that resides in a register.
44 // * Constant: an element whose value is known at compile time. 99 // * Constant: an element whose value is known at compile time.
45 100
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 int frame_arg_count); 299 int frame_arg_count);
245 300
246 // Drop a number of elements from the top of the expression stack. May 301 // Drop a number of elements from the top of the expression stack. May
247 // emit code to affect the physical frame. Does not clobber any registers 302 // emit code to affect the physical frame. Does not clobber any registers
248 // excepting possibly the stack pointer. 303 // excepting possibly the stack pointer.
249 void Drop(int count); 304 void Drop(int count);
250 305
251 // Drop one element. 306 // Drop one element.
252 void Drop(); 307 void Drop();
253 308
309 // Pop an element from the top of the expression stack.
310 // Returns a Result, which may be a constant or a register.
311 Result Pop();
312
254 // Pop and save an element from the top of the expression stack and emit a 313 // Pop and save an element from the top of the expression stack and emit a
255 // corresponding pop instruction. 314 // corresponding pop instruction.
256 void EmitPop(Register reg); 315 void EmitPop(Register reg);
257 void EmitPop(Operand operand); 316 void EmitPop(Operand operand);
258 317
259 // Push an element on top of the expression stack and emit a corresponding 318 // Push an element on top of the expression stack and emit a corresponding
260 // push instruction. 319 // push instruction.
261 void EmitPush(Register reg); 320 void EmitPush(Register reg);
262 void EmitPush(Operand operand); 321 void EmitPush(Operand operand);
263 void EmitPush(Immediate immediate); 322 void EmitPush(Immediate immediate);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 423
365 // Spill the topmost elements of the frame to memory (eg, they are the 424 // Spill the topmost elements of the frame to memory (eg, they are the
366 // arguments to a call) and all registers. 425 // arguments to a call) and all registers.
367 void PrepareForCall(int count); 426 void PrepareForCall(int count);
368 }; 427 };
369 428
370 429
371 } } // namespace v8::internal 430 } } // namespace v8::internal
372 431
373 #endif // V8_VIRTUAL_FRAME_IA32_H_ 432 #endif // V8_VIRTUAL_FRAME_IA32_H_
OLDNEW
« no previous file with comments | « no previous file | src/virtual-frame-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698