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

Unified Diff: src/virtual-frame-ia32.h

Issue 13807: Experimental: introduce factory functions for the FrameElement type.... (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/virtual-frame-ia32.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/virtual-frame-ia32.h
===================================================================
--- src/virtual-frame-ia32.h (revision 980)
+++ src/virtual-frame-ia32.h (working copy)
@@ -100,6 +100,8 @@
//
// The internal elements of the virtual frames. There are several kinds of
// elements:
+// * Invalid: elements that are uninitialized or not actually part
+// of the virtual frame. They should not be read.
// * Memory: an element that resides in the actual frame. Its address is
// given by its position in the virtual frame.
// * Register: an element that resides in a register.
@@ -107,27 +109,44 @@
class FrameElement BASE_EMBEDDED {
public:
- enum SyncFlag { SYNCED, NOT_SYNCED };
+ enum SyncFlag {
+ SYNCED,
+ NOT_SYNCED
+ };
- // Construct an in-memory frame element.
+ // The default constructor creates an invalid frame element.
FrameElement() {
- type_ = TypeField::encode(MEMORY) | SyncField::encode(SYNCED);
- // In-memory elements have no useful data.
+ type_ = TypeField::encode(INVALID) | SyncField::encode(NOT_SYNCED);
data_.reg_ = no_reg;
}
- // Construct an in-register frame element.
- FrameElement(Register reg, SyncFlag is_synced) {
- type_ = TypeField::encode(REGISTER) | SyncField::encode(is_synced);
- data_.reg_ = reg;
+ // Factory function to construct an in-memory frame element.
+ static FrameElement MemoryElement() {
+ FrameElement result;
+ result.type_ = TypeField::encode(MEMORY) | SyncField::encode(SYNCED);
+ // In-memory elements have no useful data.
+ result.data_.reg_ = no_reg;
+ return result;
}
- // Construct a frame element whose value is known at compile time.
- FrameElement(Handle<Object> value, SyncFlag is_synced) {
- type_ = TypeField::encode(CONSTANT) | SyncField::encode(is_synced);
- data_.handle_ = value.location();
+ // Factory function to construct an in-register frame element.
+ static FrameElement RegisterElement(Register reg, SyncFlag is_synced) {
+ FrameElement result;
+ result.type_ = TypeField::encode(REGISTER) | SyncField::encode(is_synced);
+ result.data_.reg_ = reg;
+ return result;
}
+ // Factory function to construct a frame element whose value is known at
+ // compile time.
+ static FrameElement ConstantElement(Handle<Object> value,
+ SyncFlag is_synced) {
+ FrameElement result;
+ result.type_ = TypeField::encode(CONSTANT) | SyncField::encode(is_synced);
+ result.data_.handle_ = value.location();
+ return result;
+ }
+
bool is_synced() const { return SyncField::decode(type_) == SYNCED; }
void set_sync() {
@@ -155,7 +174,12 @@
}
private:
- enum Type { MEMORY, REGISTER, CONSTANT };
+ enum Type {
+ INVALID,
+ MEMORY,
+ REGISTER,
+ CONSTANT
+ };
// BitField is <type, shift, size>.
class SyncField : public BitField<SyncFlag, 0, 1> {};
« 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