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

Side by Side Diff: src/scopeinfo.h

Issue 8423005: Remove some unnecessary binding initialization checks. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 1 month 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 | « src/parser.cc ('k') | src/scopeinfo.cc » ('j') | src/scopes.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 27 matching lines...) Expand all
38 // Cache for mapping (data, property name) into context slot index. 38 // Cache for mapping (data, property name) into context slot index.
39 // The cache contains both positive and negative results. 39 // The cache contains both positive and negative results.
40 // Slot index equals -1 means the property is absent. 40 // Slot index equals -1 means the property is absent.
41 // Cleared at startup and prior to mark sweep collection. 41 // Cleared at startup and prior to mark sweep collection.
42 class ContextSlotCache { 42 class ContextSlotCache {
43 public: 43 public:
44 // Lookup context slot index for (data, name). 44 // Lookup context slot index for (data, name).
45 // If absent, kNotFound is returned. 45 // If absent, kNotFound is returned.
46 int Lookup(Object* data, 46 int Lookup(Object* data,
47 String* name, 47 String* name,
48 VariableMode* mode); 48 VariableMode* mode,
49 InitializationFlag* init_flag);
49 50
50 // Update an element in the cache. 51 // Update an element in the cache.
51 void Update(Object* data, 52 void Update(Object* data,
52 String* name, 53 String* name,
53 VariableMode mode, 54 VariableMode mode,
55 InitializationFlag init_flag,
54 int slot_index); 56 int slot_index);
55 57
56 // Clear the cache. 58 // Clear the cache.
57 void Clear(); 59 void Clear();
58 60
59 static const int kNotFound = -2; 61 static const int kNotFound = -2;
60 62
61 private: 63 private:
62 ContextSlotCache() { 64 ContextSlotCache() {
63 for (int i = 0; i < kLength; ++i) { 65 for (int i = 0; i < kLength; ++i) {
64 keys_[i].data = NULL; 66 keys_[i].data = NULL;
65 keys_[i].name = NULL; 67 keys_[i].name = NULL;
66 values_[i] = kNotFound; 68 values_[i] = kNotFound;
67 } 69 }
68 } 70 }
69 71
70 inline static int Hash(Object* data, String* name); 72 inline static int Hash(Object* data, String* name);
71 73
72 #ifdef DEBUG 74 #ifdef DEBUG
73 void ValidateEntry(Object* data, 75 void ValidateEntry(Object* data,
74 String* name, 76 String* name,
75 VariableMode mode, 77 VariableMode mode,
78 InitializationFlag init_flag,
76 int slot_index); 79 int slot_index);
77 #endif 80 #endif
78 81
79 static const int kLength = 256; 82 static const int kLength = 256;
80 struct Key { 83 struct Key {
81 Object* data; 84 Object* data;
82 String* name; 85 String* name;
83 }; 86 };
84 87
85 struct Value { 88 struct Value {
86 Value(VariableMode mode, int index) { 89 Value(VariableMode mode,
90 InitializationFlag init_flag,
91 int index) {
87 ASSERT(ModeField::is_valid(mode)); 92 ASSERT(ModeField::is_valid(mode));
93 ASSERT(InitField::is_valid(init_flag));
88 ASSERT(IndexField::is_valid(index)); 94 ASSERT(IndexField::is_valid(index));
89 value_ = ModeField::encode(mode) | IndexField::encode(index); 95 value_ = ModeField::encode(mode) |
96 IndexField::encode(index) |
97 InitField::encode(init_flag);
90 ASSERT(mode == this->mode()); 98 ASSERT(mode == this->mode());
99 ASSERT(init_flag == this->initialization_flag());
91 ASSERT(index == this->index()); 100 ASSERT(index == this->index());
92 } 101 }
93 102
94 explicit inline Value(uint32_t value) : value_(value) {} 103 explicit inline Value(uint32_t value) : value_(value) {}
95 104
96 uint32_t raw() { return value_; } 105 uint32_t raw() { return value_; }
97 106
98 VariableMode mode() { return ModeField::decode(value_); } 107 VariableMode mode() { return ModeField::decode(value_); }
99 108
109 InitializationFlag initialization_flag() {
110 return InitField::decode(value_);
111 }
112
100 int index() { return IndexField::decode(value_); } 113 int index() { return IndexField::decode(value_); }
101 114
102 // Bit fields in value_ (type, shift, size). Must be public so the 115 // Bit fields in value_ (type, shift, size). Must be public so the
103 // constants can be embedded in generated code. 116 // constants can be embedded in generated code.
104 class ModeField: public BitField<VariableMode, 0, 3> {}; 117 class ModeField: public BitField<VariableMode, 0, 3> {};
105 class IndexField: public BitField<int, 3, 32-3> {}; 118 class InitField: public BitField<InitializationFlag, 3, 1> {};
119 class IndexField: public BitField<int, 4, 32-4> {};
120
106 private: 121 private:
107 uint32_t value_; 122 uint32_t value_;
108 }; 123 };
109 124
110 Key keys_[kLength]; 125 Key keys_[kLength];
111 uint32_t values_[kLength]; 126 uint32_t values_[kLength];
112 127
113 friend class Isolate; 128 friend class Isolate;
114 DISALLOW_COPY_AND_ASSIGN(ContextSlotCache); 129 DISALLOW_COPY_AND_ASSIGN(ContextSlotCache);
115 }; 130 };
116 131
117 132
118 } } // namespace v8::internal 133 } } // namespace v8::internal
119 134
120 #endif // V8_SCOPEINFO_H_ 135 #endif // V8_SCOPEINFO_H_
OLDNEW
« no previous file with comments | « src/parser.cc ('k') | src/scopeinfo.cc » ('j') | src/scopes.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698