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

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

Issue 15037: Experimental: use the Result class to manage the lifetime of registers... (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
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 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 if (is_register()) {
54 Unuse();
55 }
56 }
57
58 void Unuse();
59
60 bool is_register() const { return type() == REGISTER; }
61 bool is_constant() const { return type() == CONSTANT; }
62 bool is_valid() const { return type() != INVALID; }
63
64 Register reg() const {
65 ASSERT(type() == REGISTER);
66 return data_.reg_;
67 }
68
69 Handle<Object> handle() const {
70 ASSERT(type() == CONSTANT);
71 return Handle<Object>(data_.handle_);
72 }
73
74 // Change a result to a register result. If the result is not already
75 // in a register, allocate a register from the code generator, and emit
76 // code to move the value into that register.
77 void ToRegister();
78 private:
79 enum Type {
80 REGISTER,
81 CONSTANT,
82 INVALID
83 };
84
85 Type type_;
86
87 Type type() const { return type_; }
88
89 union {
90 Register reg_;
91 Object** handle_;
92 } data_;
93
94 CodeGenerator* cgen_;
95 };
96
97
98 // ------------------------------------------------------------------------- 36 // -------------------------------------------------------------------------
99 // Virtual frame elements 37 // Virtual frame elements
100 // 38 //
101 // The internal elements of the virtual frames. There are several kinds of 39 // The internal elements of the virtual frames. There are several kinds of
102 // elements: 40 // elements:
103 // * Invalid: elements that are uninitialized or not actually part 41 // * Invalid: elements that are uninitialized or not actually part
104 // of the virtual frame. They should not be read. 42 // of the virtual frame. They should not be read.
105 // * Memory: an element that resides in the actual frame. Its address is 43 // * Memory: an element that resides in the actual frame. Its address is
106 // given by its position in the virtual frame. 44 // given by its position in the virtual frame.
107 // * Register: an element that resides in a register. 45 // * Register: an element that resides in a register.
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 // Push an element on top of the expression stack and emit a corresponding 332 // Push an element on top of the expression stack and emit a corresponding
395 // push instruction. 333 // push instruction.
396 void EmitPush(Register reg); 334 void EmitPush(Register reg);
397 void EmitPush(Operand operand); 335 void EmitPush(Operand operand);
398 void EmitPush(Immediate immediate); 336 void EmitPush(Immediate immediate);
399 337
400 // Push an element on the virtual frame. 338 // Push an element on the virtual frame.
401 void Push(Register reg); 339 void Push(Register reg);
402 void Push(Handle<Object> value); 340 void Push(Handle<Object> value);
403 341
342 // Pushing a result invalidates it (its contents become owned by the
343 // frame).
344 void Push(Result* result);
345
404 #ifdef DEBUG 346 #ifdef DEBUG
405 bool IsSpilled(); 347 bool IsSpilled();
406 #endif 348 #endif
407 349
408 private: 350 private:
409 // An illegal index into the virtual frame. 351 // An illegal index into the virtual frame.
410 static const int kIllegalIndex = -1; 352 static const int kIllegalIndex = -1;
411 353
412 static const int kLocal0Offset = JavaScriptFrameConstants::kLocal0Offset; 354 static const int kLocal0Offset = JavaScriptFrameConstants::kLocal0Offset;
413 static const int kFunctionOffset = JavaScriptFrameConstants::kFunctionOffset; 355 static const int kFunctionOffset = JavaScriptFrameConstants::kFunctionOffset;
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 // Called after all register-to-memory and register-to-register 471 // Called after all register-to-memory and register-to-register
530 // moves have been made. After this function returns, the frames 472 // moves have been made. After this function returns, the frames
531 // should be equal. 473 // should be equal.
532 void MergeMoveMemoryToRegisters(VirtualFrame *expected); 474 void MergeMoveMemoryToRegisters(VirtualFrame *expected);
533 }; 475 };
534 476
535 477
536 } } // namespace v8::internal 478 } } // namespace v8::internal
537 479
538 #endif // V8_VIRTUAL_FRAME_IA32_H_ 480 #endif // V8_VIRTUAL_FRAME_IA32_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698