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

Side by Side Diff: src/stub-cache.cc

Issue 6685088: Merge isolates to bleeding_edge. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 9 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
« no previous file with comments | « src/stub-cache.h ('k') | src/token.h » ('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 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-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 23 matching lines...) Expand all
34 #include "stub-cache.h" 34 #include "stub-cache.h"
35 #include "vm-state-inl.h" 35 #include "vm-state-inl.h"
36 36
37 namespace v8 { 37 namespace v8 {
38 namespace internal { 38 namespace internal {
39 39
40 // ----------------------------------------------------------------------- 40 // -----------------------------------------------------------------------
41 // StubCache implementation. 41 // StubCache implementation.
42 42
43 43
44 StubCache::Entry StubCache::primary_[StubCache::kPrimaryTableSize]; 44 StubCache::StubCache(Isolate* isolate) : isolate_(isolate) {
45 StubCache::Entry StubCache::secondary_[StubCache::kSecondaryTableSize]; 45 ASSERT(isolate == Isolate::Current());
46 memset(primary_, 0, sizeof(primary_[0]) * StubCache::kPrimaryTableSize);
47 memset(secondary_, 0, sizeof(secondary_[0]) * StubCache::kSecondaryTableSize);
48 }
49
46 50
47 void StubCache::Initialize(bool create_heap_objects) { 51 void StubCache::Initialize(bool create_heap_objects) {
48 ASSERT(IsPowerOf2(kPrimaryTableSize)); 52 ASSERT(IsPowerOf2(kPrimaryTableSize));
49 ASSERT(IsPowerOf2(kSecondaryTableSize)); 53 ASSERT(IsPowerOf2(kSecondaryTableSize));
50 if (create_heap_objects) { 54 if (create_heap_objects) {
51 HandleScope scope; 55 HandleScope scope;
52 Clear(); 56 Clear();
53 } 57 }
54 } 58 }
55 59
56 60
57 Code* StubCache::Set(String* name, Map* map, Code* code) { 61 Code* StubCache::Set(String* name, Map* map, Code* code) {
58 // Get the flags from the code. 62 // Get the flags from the code.
59 Code::Flags flags = Code::RemoveTypeFromFlags(code->flags()); 63 Code::Flags flags = Code::RemoveTypeFromFlags(code->flags());
60 64
61 // Validate that the name does not move on scavenge, and that we 65 // Validate that the name does not move on scavenge, and that we
62 // can use identity checks instead of string equality checks. 66 // can use identity checks instead of string equality checks.
63 ASSERT(!Heap::InNewSpace(name)); 67 ASSERT(!isolate_->heap()->InNewSpace(name));
64 ASSERT(name->IsSymbol()); 68 ASSERT(name->IsSymbol());
65 69
66 // The state bits are not important to the hash function because 70 // The state bits are not important to the hash function because
67 // the stub cache only contains monomorphic stubs. Make sure that 71 // the stub cache only contains monomorphic stubs. Make sure that
68 // the bits are the least significant so they will be the ones 72 // the bits are the least significant so they will be the ones
69 // masked out. 73 // masked out.
70 ASSERT(Code::ExtractICStateFromFlags(flags) == MONOMORPHIC); 74 ASSERT(Code::ExtractICStateFromFlags(flags) == MONOMORPHIC);
71 ASSERT(Code::kFlagsICStateShift == 0); 75 ASSERT(Code::kFlagsICStateShift == 0);
72 76
73 // Make sure that the code type is not included in the hash. 77 // Make sure that the code type is not included in the hash.
74 ASSERT(Code::ExtractTypeFromFlags(flags) == 0); 78 ASSERT(Code::ExtractTypeFromFlags(flags) == 0);
75 79
76 // Compute the primary entry. 80 // Compute the primary entry.
77 int primary_offset = PrimaryOffset(name, flags, map); 81 int primary_offset = PrimaryOffset(name, flags, map);
78 Entry* primary = entry(primary_, primary_offset); 82 Entry* primary = entry(primary_, primary_offset);
79 Code* hit = primary->value; 83 Code* hit = primary->value;
80 84
81 // If the primary entry has useful data in it, we retire it to the 85 // If the primary entry has useful data in it, we retire it to the
82 // secondary cache before overwriting it. 86 // secondary cache before overwriting it.
83 if (hit != Builtins::builtin(Builtins::Illegal)) { 87 if (hit != isolate_->builtins()->builtin(Builtins::Illegal)) {
84 Code::Flags primary_flags = Code::RemoveTypeFromFlags(hit->flags()); 88 Code::Flags primary_flags = Code::RemoveTypeFromFlags(hit->flags());
85 int secondary_offset = 89 int secondary_offset =
86 SecondaryOffset(primary->key, primary_flags, primary_offset); 90 SecondaryOffset(primary->key, primary_flags, primary_offset);
87 Entry* secondary = entry(secondary_, secondary_offset); 91 Entry* secondary = entry(secondary_, secondary_offset);
88 *secondary = *primary; 92 *secondary = *primary;
89 } 93 }
90 94
91 // Update primary cache. 95 // Update primary cache.
92 primary->key = name; 96 primary->key = name;
93 primary->value = code; 97 primary->value = code;
94 return code; 98 return code;
95 } 99 }
96 100
97 101
98 MaybeObject* StubCache::ComputeLoadNonexistent(String* name, 102 MaybeObject* StubCache::ComputeLoadNonexistent(String* name,
99 JSObject* receiver) { 103 JSObject* receiver) {
100 ASSERT(receiver->IsGlobalObject() || receiver->HasFastProperties()); 104 ASSERT(receiver->IsGlobalObject() || receiver->HasFastProperties());
101 // If no global objects are present in the prototype chain, the load 105 // If no global objects are present in the prototype chain, the load
102 // nonexistent IC stub can be shared for all names for a given map 106 // nonexistent IC stub can be shared for all names for a given map
103 // and we use the empty string for the map cache in that case. If 107 // and we use the empty string for the map cache in that case. If
104 // there are global objects involved, we need to check global 108 // there are global objects involved, we need to check global
105 // property cells in the stub and therefore the stub will be 109 // property cells in the stub and therefore the stub will be
106 // specific to the name. 110 // specific to the name.
107 String* cache_name = Heap::empty_string(); 111 String* cache_name = isolate_->heap()->empty_string();
108 if (receiver->IsGlobalObject()) cache_name = name; 112 if (receiver->IsGlobalObject()) cache_name = name;
109 JSObject* last = receiver; 113 JSObject* last = receiver;
110 while (last->GetPrototype() != Heap::null_value()) { 114 while (last->GetPrototype() != isolate_->heap()->null_value()) {
111 last = JSObject::cast(last->GetPrototype()); 115 last = JSObject::cast(last->GetPrototype());
112 if (last->IsGlobalObject()) cache_name = name; 116 if (last->IsGlobalObject()) cache_name = name;
113 } 117 }
114 // Compile the stub that is either shared for all names or 118 // Compile the stub that is either shared for all names or
115 // name specific if there are global objects involved. 119 // name specific if there are global objects involved.
116 Code::Flags flags = 120 Code::Flags flags =
117 Code::ComputeMonomorphicFlags(Code::LOAD_IC, NONEXISTENT); 121 Code::ComputeMonomorphicFlags(Code::LOAD_IC, NONEXISTENT);
118 Object* code = receiver->map()->FindInCodeCache(cache_name, flags); 122 Object* code = receiver->map()->FindInCodeCache(cache_name, flags);
119 if (code->IsUndefined()) { 123 if (code->IsUndefined()) {
120 LoadStubCompiler compiler; 124 LoadStubCompiler compiler;
121 { MaybeObject* maybe_code = 125 { MaybeObject* maybe_code =
122 compiler.CompileLoadNonexistent(cache_name, receiver, last); 126 compiler.CompileLoadNonexistent(cache_name, receiver, last);
123 if (!maybe_code->ToObject(&code)) return maybe_code; 127 if (!maybe_code->ToObject(&code)) return maybe_code;
124 } 128 }
125 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), cache_name)); 129 PROFILE(isolate_,
130 CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), cache_name));
126 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, cache_name, Code::cast(code))); 131 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, cache_name, Code::cast(code)));
127 Object* result; 132 Object* result;
128 { MaybeObject* maybe_result = 133 { MaybeObject* maybe_result =
129 receiver->UpdateMapCodeCache(cache_name, Code::cast(code)); 134 receiver->UpdateMapCodeCache(cache_name, Code::cast(code));
130 if (!maybe_result->ToObject(&result)) return maybe_result; 135 if (!maybe_result->ToObject(&result)) return maybe_result;
131 } 136 }
132 } 137 }
133 return code; 138 return code;
134 } 139 }
135 140
136 141
137 MaybeObject* StubCache::ComputeLoadField(String* name, 142 MaybeObject* StubCache::ComputeLoadField(String* name,
138 JSObject* receiver, 143 JSObject* receiver,
139 JSObject* holder, 144 JSObject* holder,
140 int field_index) { 145 int field_index) {
141 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); 146 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP);
142 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, FIELD); 147 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, FIELD);
143 Object* code = receiver->map()->FindInCodeCache(name, flags); 148 Object* code = receiver->map()->FindInCodeCache(name, flags);
144 if (code->IsUndefined()) { 149 if (code->IsUndefined()) {
145 LoadStubCompiler compiler; 150 LoadStubCompiler compiler;
146 { MaybeObject* maybe_code = 151 { MaybeObject* maybe_code =
147 compiler.CompileLoadField(receiver, holder, field_index, name); 152 compiler.CompileLoadField(receiver, holder, field_index, name);
148 if (!maybe_code->ToObject(&code)) return maybe_code; 153 if (!maybe_code->ToObject(&code)) return maybe_code;
149 } 154 }
150 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name)); 155 PROFILE(isolate_,
156 CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name));
151 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, name, Code::cast(code))); 157 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, name, Code::cast(code)));
152 Object* result; 158 Object* result;
153 { MaybeObject* maybe_result = 159 { MaybeObject* maybe_result =
154 receiver->UpdateMapCodeCache(name, Code::cast(code)); 160 receiver->UpdateMapCodeCache(name, Code::cast(code));
155 if (!maybe_result->ToObject(&result)) return maybe_result; 161 if (!maybe_result->ToObject(&result)) return maybe_result;
156 } 162 }
157 } 163 }
158 return code; 164 return code;
159 } 165 }
160 166
161 167
162 MaybeObject* StubCache::ComputeLoadCallback(String* name, 168 MaybeObject* StubCache::ComputeLoadCallback(String* name,
163 JSObject* receiver, 169 JSObject* receiver,
164 JSObject* holder, 170 JSObject* holder,
165 AccessorInfo* callback) { 171 AccessorInfo* callback) {
166 ASSERT(v8::ToCData<Address>(callback->getter()) != 0); 172 ASSERT(v8::ToCData<Address>(callback->getter()) != 0);
167 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); 173 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP);
168 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, CALLBACKS); 174 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, CALLBACKS);
169 Object* code = receiver->map()->FindInCodeCache(name, flags); 175 Object* code = receiver->map()->FindInCodeCache(name, flags);
170 if (code->IsUndefined()) { 176 if (code->IsUndefined()) {
171 LoadStubCompiler compiler; 177 LoadStubCompiler compiler;
172 { MaybeObject* maybe_code = 178 { MaybeObject* maybe_code =
173 compiler.CompileLoadCallback(name, receiver, holder, callback); 179 compiler.CompileLoadCallback(name, receiver, holder, callback);
174 if (!maybe_code->ToObject(&code)) return maybe_code; 180 if (!maybe_code->ToObject(&code)) return maybe_code;
175 } 181 }
176 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name)); 182 PROFILE(isolate_,
183 CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name));
177 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, name, Code::cast(code))); 184 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, name, Code::cast(code)));
178 Object* result; 185 Object* result;
179 { MaybeObject* maybe_result = 186 { MaybeObject* maybe_result =
180 receiver->UpdateMapCodeCache(name, Code::cast(code)); 187 receiver->UpdateMapCodeCache(name, Code::cast(code));
181 if (!maybe_result->ToObject(&result)) return maybe_result; 188 if (!maybe_result->ToObject(&result)) return maybe_result;
182 } 189 }
183 } 190 }
184 return code; 191 return code;
185 } 192 }
186 193
187 194
188 MaybeObject* StubCache::ComputeLoadConstant(String* name, 195 MaybeObject* StubCache::ComputeLoadConstant(String* name,
189 JSObject* receiver, 196 JSObject* receiver,
190 JSObject* holder, 197 JSObject* holder,
191 Object* value) { 198 Object* value) {
192 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); 199 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP);
193 Code::Flags flags = 200 Code::Flags flags =
194 Code::ComputeMonomorphicFlags(Code::LOAD_IC, CONSTANT_FUNCTION); 201 Code::ComputeMonomorphicFlags(Code::LOAD_IC, CONSTANT_FUNCTION);
195 Object* code = receiver->map()->FindInCodeCache(name, flags); 202 Object* code = receiver->map()->FindInCodeCache(name, flags);
196 if (code->IsUndefined()) { 203 if (code->IsUndefined()) {
197 LoadStubCompiler compiler; 204 LoadStubCompiler compiler;
198 { MaybeObject* maybe_code = 205 { MaybeObject* maybe_code =
199 compiler.CompileLoadConstant(receiver, holder, value, name); 206 compiler.CompileLoadConstant(receiver, holder, value, name);
200 if (!maybe_code->ToObject(&code)) return maybe_code; 207 if (!maybe_code->ToObject(&code)) return maybe_code;
201 } 208 }
202 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name)); 209 PROFILE(isolate_,
210 CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name));
203 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, name, Code::cast(code))); 211 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, name, Code::cast(code)));
204 Object* result; 212 Object* result;
205 { MaybeObject* maybe_result = 213 { MaybeObject* maybe_result =
206 receiver->UpdateMapCodeCache(name, Code::cast(code)); 214 receiver->UpdateMapCodeCache(name, Code::cast(code));
207 if (!maybe_result->ToObject(&result)) return maybe_result; 215 if (!maybe_result->ToObject(&result)) return maybe_result;
208 } 216 }
209 } 217 }
210 return code; 218 return code;
211 } 219 }
212 220
213 221
214 MaybeObject* StubCache::ComputeLoadInterceptor(String* name, 222 MaybeObject* StubCache::ComputeLoadInterceptor(String* name,
215 JSObject* receiver, 223 JSObject* receiver,
216 JSObject* holder) { 224 JSObject* holder) {
217 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); 225 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP);
218 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, INTERCEPTOR); 226 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, INTERCEPTOR);
219 Object* code = receiver->map()->FindInCodeCache(name, flags); 227 Object* code = receiver->map()->FindInCodeCache(name, flags);
220 if (code->IsUndefined()) { 228 if (code->IsUndefined()) {
221 LoadStubCompiler compiler; 229 LoadStubCompiler compiler;
222 { MaybeObject* maybe_code = 230 { MaybeObject* maybe_code =
223 compiler.CompileLoadInterceptor(receiver, holder, name); 231 compiler.CompileLoadInterceptor(receiver, holder, name);
224 if (!maybe_code->ToObject(&code)) return maybe_code; 232 if (!maybe_code->ToObject(&code)) return maybe_code;
225 } 233 }
226 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name)); 234 PROFILE(isolate_,
235 CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name));
227 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, name, Code::cast(code))); 236 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, name, Code::cast(code)));
228 Object* result; 237 Object* result;
229 { MaybeObject* maybe_result = 238 { MaybeObject* maybe_result =
230 receiver->UpdateMapCodeCache(name, Code::cast(code)); 239 receiver->UpdateMapCodeCache(name, Code::cast(code));
231 if (!maybe_result->ToObject(&result)) return maybe_result; 240 if (!maybe_result->ToObject(&result)) return maybe_result;
232 } 241 }
233 } 242 }
234 return code; 243 return code;
235 } 244 }
236 245
237 246
238 MaybeObject* StubCache::ComputeLoadNormal() { 247 MaybeObject* StubCache::ComputeLoadNormal() {
239 return Builtins::builtin(Builtins::LoadIC_Normal); 248 return isolate_->builtins()->builtin(Builtins::LoadIC_Normal);
240 } 249 }
241 250
242 251
243 MaybeObject* StubCache::ComputeLoadGlobal(String* name, 252 MaybeObject* StubCache::ComputeLoadGlobal(String* name,
244 JSObject* receiver, 253 JSObject* receiver,
245 GlobalObject* holder, 254 GlobalObject* holder,
246 JSGlobalPropertyCell* cell, 255 JSGlobalPropertyCell* cell,
247 bool is_dont_delete) { 256 bool is_dont_delete) {
248 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); 257 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP);
249 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, NORMAL); 258 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, NORMAL);
250 Object* code = receiver->map()->FindInCodeCache(name, flags); 259 Object* code = receiver->map()->FindInCodeCache(name, flags);
251 if (code->IsUndefined()) { 260 if (code->IsUndefined()) {
252 LoadStubCompiler compiler; 261 LoadStubCompiler compiler;
253 { MaybeObject* maybe_code = compiler.CompileLoadGlobal(receiver, 262 { MaybeObject* maybe_code = compiler.CompileLoadGlobal(receiver,
254 holder, 263 holder,
255 cell, 264 cell,
256 name, 265 name,
257 is_dont_delete); 266 is_dont_delete);
258 if (!maybe_code->ToObject(&code)) return maybe_code; 267 if (!maybe_code->ToObject(&code)) return maybe_code;
259 } 268 }
260 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name)); 269 PROFILE(isolate_,
270 CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name));
261 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, name, Code::cast(code))); 271 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, name, Code::cast(code)));
262 Object* result; 272 Object* result;
263 { MaybeObject* maybe_result = 273 { MaybeObject* maybe_result =
264 receiver->UpdateMapCodeCache(name, Code::cast(code)); 274 receiver->UpdateMapCodeCache(name, Code::cast(code));
265 if (!maybe_result->ToObject(&result)) return maybe_result; 275 if (!maybe_result->ToObject(&result)) return maybe_result;
266 } 276 }
267 } 277 }
268 return code; 278 return code;
269 } 279 }
270 280
271 281
272 MaybeObject* StubCache::ComputeKeyedLoadField(String* name, 282 MaybeObject* StubCache::ComputeKeyedLoadField(String* name,
273 JSObject* receiver, 283 JSObject* receiver,
274 JSObject* holder, 284 JSObject* holder,
275 int field_index) { 285 int field_index) {
276 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); 286 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP);
277 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, FIELD); 287 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, FIELD);
278 Object* code = receiver->map()->FindInCodeCache(name, flags); 288 Object* code = receiver->map()->FindInCodeCache(name, flags);
279 if (code->IsUndefined()) { 289 if (code->IsUndefined()) {
280 KeyedLoadStubCompiler compiler; 290 KeyedLoadStubCompiler compiler;
281 { MaybeObject* maybe_code = 291 { MaybeObject* maybe_code =
282 compiler.CompileLoadField(name, receiver, holder, field_index); 292 compiler.CompileLoadField(name, receiver, holder, field_index);
283 if (!maybe_code->ToObject(&code)) return maybe_code; 293 if (!maybe_code->ToObject(&code)) return maybe_code;
284 } 294 }
285 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); 295 PROFILE(isolate_,
296 CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name));
286 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, name, Code::cast(code))); 297 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, name, Code::cast(code)));
287 Object* result; 298 Object* result;
288 { MaybeObject* maybe_result = 299 { MaybeObject* maybe_result =
289 receiver->UpdateMapCodeCache(name, Code::cast(code)); 300 receiver->UpdateMapCodeCache(name, Code::cast(code));
290 if (!maybe_result->ToObject(&result)) return maybe_result; 301 if (!maybe_result->ToObject(&result)) return maybe_result;
291 } 302 }
292 } 303 }
293 return code; 304 return code;
294 } 305 }
295 306
296 307
297 MaybeObject* StubCache::ComputeKeyedLoadConstant(String* name, 308 MaybeObject* StubCache::ComputeKeyedLoadConstant(String* name,
298 JSObject* receiver, 309 JSObject* receiver,
299 JSObject* holder, 310 JSObject* holder,
300 Object* value) { 311 Object* value) {
301 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); 312 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP);
302 Code::Flags flags = 313 Code::Flags flags =
303 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CONSTANT_FUNCTION); 314 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CONSTANT_FUNCTION);
304 Object* code = receiver->map()->FindInCodeCache(name, flags); 315 Object* code = receiver->map()->FindInCodeCache(name, flags);
305 if (code->IsUndefined()) { 316 if (code->IsUndefined()) {
306 KeyedLoadStubCompiler compiler; 317 KeyedLoadStubCompiler compiler;
307 { MaybeObject* maybe_code = 318 { MaybeObject* maybe_code =
308 compiler.CompileLoadConstant(name, receiver, holder, value); 319 compiler.CompileLoadConstant(name, receiver, holder, value);
309 if (!maybe_code->ToObject(&code)) return maybe_code; 320 if (!maybe_code->ToObject(&code)) return maybe_code;
310 } 321 }
311 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); 322 PROFILE(isolate_,
323 CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name));
312 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, name, Code::cast(code))); 324 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, name, Code::cast(code)));
313 Object* result; 325 Object* result;
314 { MaybeObject* maybe_result = 326 { MaybeObject* maybe_result =
315 receiver->UpdateMapCodeCache(name, Code::cast(code)); 327 receiver->UpdateMapCodeCache(name, Code::cast(code));
316 if (!maybe_result->ToObject(&result)) return maybe_result; 328 if (!maybe_result->ToObject(&result)) return maybe_result;
317 } 329 }
318 } 330 }
319 return code; 331 return code;
320 } 332 }
321 333
322 334
323 MaybeObject* StubCache::ComputeKeyedLoadInterceptor(String* name, 335 MaybeObject* StubCache::ComputeKeyedLoadInterceptor(String* name,
324 JSObject* receiver, 336 JSObject* receiver,
325 JSObject* holder) { 337 JSObject* holder) {
326 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); 338 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP);
327 Code::Flags flags = 339 Code::Flags flags =
328 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, INTERCEPTOR); 340 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, INTERCEPTOR);
329 Object* code = receiver->map()->FindInCodeCache(name, flags); 341 Object* code = receiver->map()->FindInCodeCache(name, flags);
330 if (code->IsUndefined()) { 342 if (code->IsUndefined()) {
331 KeyedLoadStubCompiler compiler; 343 KeyedLoadStubCompiler compiler;
332 { MaybeObject* maybe_code = 344 { MaybeObject* maybe_code =
333 compiler.CompileLoadInterceptor(receiver, holder, name); 345 compiler.CompileLoadInterceptor(receiver, holder, name);
334 if (!maybe_code->ToObject(&code)) return maybe_code; 346 if (!maybe_code->ToObject(&code)) return maybe_code;
335 } 347 }
336 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); 348 PROFILE(isolate_,
349 CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name));
337 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, name, Code::cast(code))); 350 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, name, Code::cast(code)));
338 Object* result; 351 Object* result;
339 { MaybeObject* maybe_result = 352 { MaybeObject* maybe_result =
340 receiver->UpdateMapCodeCache(name, Code::cast(code)); 353 receiver->UpdateMapCodeCache(name, Code::cast(code));
341 if (!maybe_result->ToObject(&result)) return maybe_result; 354 if (!maybe_result->ToObject(&result)) return maybe_result;
342 } 355 }
343 } 356 }
344 return code; 357 return code;
345 } 358 }
346 359
347 360
348 MaybeObject* StubCache::ComputeKeyedLoadCallback(String* name, 361 MaybeObject* StubCache::ComputeKeyedLoadCallback(String* name,
349 JSObject* receiver, 362 JSObject* receiver,
350 JSObject* holder, 363 JSObject* holder,
351 AccessorInfo* callback) { 364 AccessorInfo* callback) {
352 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); 365 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP);
353 Code::Flags flags = 366 Code::Flags flags =
354 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CALLBACKS); 367 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CALLBACKS);
355 Object* code = receiver->map()->FindInCodeCache(name, flags); 368 Object* code = receiver->map()->FindInCodeCache(name, flags);
356 if (code->IsUndefined()) { 369 if (code->IsUndefined()) {
357 KeyedLoadStubCompiler compiler; 370 KeyedLoadStubCompiler compiler;
358 { MaybeObject* maybe_code = 371 { MaybeObject* maybe_code =
359 compiler.CompileLoadCallback(name, receiver, holder, callback); 372 compiler.CompileLoadCallback(name, receiver, holder, callback);
360 if (!maybe_code->ToObject(&code)) return maybe_code; 373 if (!maybe_code->ToObject(&code)) return maybe_code;
361 } 374 }
362 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); 375 PROFILE(isolate_,
376 CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name));
363 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, name, Code::cast(code))); 377 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, name, Code::cast(code)));
364 Object* result; 378 Object* result;
365 { MaybeObject* maybe_result = 379 { MaybeObject* maybe_result =
366 receiver->UpdateMapCodeCache(name, Code::cast(code)); 380 receiver->UpdateMapCodeCache(name, Code::cast(code));
367 if (!maybe_result->ToObject(&result)) return maybe_result; 381 if (!maybe_result->ToObject(&result)) return maybe_result;
368 } 382 }
369 } 383 }
370 return code; 384 return code;
371 } 385 }
372 386
373 387
374 388
375 MaybeObject* StubCache::ComputeKeyedLoadArrayLength(String* name, 389 MaybeObject* StubCache::ComputeKeyedLoadArrayLength(String* name,
376 JSArray* receiver) { 390 JSArray* receiver) {
377 Code::Flags flags = 391 Code::Flags flags =
378 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CALLBACKS); 392 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CALLBACKS);
379 ASSERT(receiver->IsJSObject()); 393 ASSERT(receiver->IsJSObject());
380 Object* code = receiver->map()->FindInCodeCache(name, flags); 394 Object* code = receiver->map()->FindInCodeCache(name, flags);
381 if (code->IsUndefined()) { 395 if (code->IsUndefined()) {
382 KeyedLoadStubCompiler compiler; 396 KeyedLoadStubCompiler compiler;
383 { MaybeObject* maybe_code = compiler.CompileLoadArrayLength(name); 397 { MaybeObject* maybe_code = compiler.CompileLoadArrayLength(name);
384 if (!maybe_code->ToObject(&code)) return maybe_code; 398 if (!maybe_code->ToObject(&code)) return maybe_code;
385 } 399 }
386 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); 400 PROFILE(isolate_,
401 CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name));
387 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, name, Code::cast(code))); 402 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, name, Code::cast(code)));
388 Object* result; 403 Object* result;
389 { MaybeObject* maybe_result = 404 { MaybeObject* maybe_result =
390 receiver->UpdateMapCodeCache(name, Code::cast(code)); 405 receiver->UpdateMapCodeCache(name, Code::cast(code));
391 if (!maybe_result->ToObject(&result)) return maybe_result; 406 if (!maybe_result->ToObject(&result)) return maybe_result;
392 } 407 }
393 } 408 }
394 return code; 409 return code;
395 } 410 }
396 411
397 412
398 MaybeObject* StubCache::ComputeKeyedLoadStringLength(String* name, 413 MaybeObject* StubCache::ComputeKeyedLoadStringLength(String* name,
399 String* receiver) { 414 String* receiver) {
400 Code::Flags flags = 415 Code::Flags flags =
401 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CALLBACKS); 416 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CALLBACKS);
402 Map* map = receiver->map(); 417 Map* map = receiver->map();
403 Object* code = map->FindInCodeCache(name, flags); 418 Object* code = map->FindInCodeCache(name, flags);
404 if (code->IsUndefined()) { 419 if (code->IsUndefined()) {
405 KeyedLoadStubCompiler compiler; 420 KeyedLoadStubCompiler compiler;
406 { MaybeObject* maybe_code = compiler.CompileLoadStringLength(name); 421 { MaybeObject* maybe_code = compiler.CompileLoadStringLength(name);
407 if (!maybe_code->ToObject(&code)) return maybe_code; 422 if (!maybe_code->ToObject(&code)) return maybe_code;
408 } 423 }
409 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); 424 PROFILE(isolate_,
425 CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name));
410 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, name, Code::cast(code))); 426 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, name, Code::cast(code)));
411 Object* result; 427 Object* result;
412 { MaybeObject* maybe_result = map->UpdateCodeCache(name, Code::cast(code)); 428 { MaybeObject* maybe_result = map->UpdateCodeCache(name, Code::cast(code));
413 if (!maybe_result->ToObject(&result)) return maybe_result; 429 if (!maybe_result->ToObject(&result)) return maybe_result;
414 } 430 }
415 } 431 }
416 return code; 432 return code;
417 } 433 }
418 434
419 435
420 MaybeObject* StubCache::ComputeKeyedLoadFunctionPrototype( 436 MaybeObject* StubCache::ComputeKeyedLoadFunctionPrototype(
421 String* name, 437 String* name,
422 JSFunction* receiver) { 438 JSFunction* receiver) {
423 Code::Flags flags = 439 Code::Flags flags =
424 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CALLBACKS); 440 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CALLBACKS);
425 Object* code = receiver->map()->FindInCodeCache(name, flags); 441 Object* code = receiver->map()->FindInCodeCache(name, flags);
426 if (code->IsUndefined()) { 442 if (code->IsUndefined()) {
427 KeyedLoadStubCompiler compiler; 443 KeyedLoadStubCompiler compiler;
428 { MaybeObject* maybe_code = compiler.CompileLoadFunctionPrototype(name); 444 { MaybeObject* maybe_code = compiler.CompileLoadFunctionPrototype(name);
429 if (!maybe_code->ToObject(&code)) return maybe_code; 445 if (!maybe_code->ToObject(&code)) return maybe_code;
430 } 446 }
431 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); 447 PROFILE(isolate_,
448 CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name));
432 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, name, Code::cast(code))); 449 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, name, Code::cast(code)));
433 Object* result; 450 Object* result;
434 { MaybeObject* maybe_result = 451 { MaybeObject* maybe_result =
435 receiver->UpdateMapCodeCache(name, Code::cast(code)); 452 receiver->UpdateMapCodeCache(name, Code::cast(code));
436 if (!maybe_result->ToObject(&result)) return maybe_result; 453 if (!maybe_result->ToObject(&result)) return maybe_result;
437 } 454 }
438 } 455 }
439 return code; 456 return code;
440 } 457 }
441 458
442 459
443 MaybeObject* StubCache::ComputeKeyedLoadSpecialized(JSObject* receiver) { 460 MaybeObject* StubCache::ComputeKeyedLoadSpecialized(JSObject* receiver) {
444 // Using NORMAL as the PropertyType for array element loads is a misuse. The 461 // Using NORMAL as the PropertyType for array element loads is a misuse. The
445 // generated stub always accesses fast elements, not slow-mode fields, but 462 // generated stub always accesses fast elements, not slow-mode fields, but
446 // some property type is required for the stub lookup. Note that overloading 463 // some property type is required for the stub lookup. Note that overloading
447 // the NORMAL PropertyType is only safe as long as no stubs are generated for 464 // the NORMAL PropertyType is only safe as long as no stubs are generated for
448 // other keyed field loads. This is guaranteed to be the case since all field 465 // other keyed field loads. This is guaranteed to be the case since all field
449 // keyed loads that are not array elements go through a generic builtin stub. 466 // keyed loads that are not array elements go through a generic builtin stub.
450 Code::Flags flags = 467 Code::Flags flags =
451 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, NORMAL); 468 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, NORMAL);
452 String* name = Heap::KeyedLoadSpecialized_symbol(); 469 String* name = isolate_->heap()->KeyedLoadSpecialized_symbol();
453 Object* code = receiver->map()->FindInCodeCache(name, flags); 470 Object* code = receiver->map()->FindInCodeCache(name, flags);
454 if (code->IsUndefined()) { 471 if (code->IsUndefined()) {
455 KeyedLoadStubCompiler compiler; 472 KeyedLoadStubCompiler compiler;
456 { MaybeObject* maybe_code = compiler.CompileLoadSpecialized(receiver); 473 { MaybeObject* maybe_code = compiler.CompileLoadSpecialized(receiver);
457 if (!maybe_code->ToObject(&code)) return maybe_code; 474 if (!maybe_code->ToObject(&code)) return maybe_code;
458 } 475 }
459 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), 0)); 476 PROFILE(isolate_,
477 CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), 0));
460 Object* result; 478 Object* result;
461 { MaybeObject* maybe_result = 479 { MaybeObject* maybe_result =
462 receiver->UpdateMapCodeCache(name, Code::cast(code)); 480 receiver->UpdateMapCodeCache(name, Code::cast(code));
463 if (!maybe_result->ToObject(&result)) return maybe_result; 481 if (!maybe_result->ToObject(&result)) return maybe_result;
464 } 482 }
465 } 483 }
466 return code; 484 return code;
467 } 485 }
468 486
469 487
470 MaybeObject* StubCache::ComputeStoreField(String* name, 488 MaybeObject* StubCache::ComputeStoreField(String* name,
471 JSObject* receiver, 489 JSObject* receiver,
472 int field_index, 490 int field_index,
473 Map* transition, 491 Map* transition,
474 StrictModeFlag strict_mode) { 492 StrictModeFlag strict_mode) {
475 PropertyType type = (transition == NULL) ? FIELD : MAP_TRANSITION; 493 PropertyType type = (transition == NULL) ? FIELD : MAP_TRANSITION;
476 Code::Flags flags = Code::ComputeMonomorphicFlags( 494 Code::Flags flags = Code::ComputeMonomorphicFlags(
477 Code::STORE_IC, type, strict_mode); 495 Code::STORE_IC, type, strict_mode);
478 Object* code = receiver->map()->FindInCodeCache(name, flags); 496 Object* code = receiver->map()->FindInCodeCache(name, flags);
479 if (code->IsUndefined()) { 497 if (code->IsUndefined()) {
480 StoreStubCompiler compiler(strict_mode); 498 StoreStubCompiler compiler(strict_mode);
481 { MaybeObject* maybe_code = 499 { MaybeObject* maybe_code =
482 compiler.CompileStoreField(receiver, field_index, transition, name); 500 compiler.CompileStoreField(receiver, field_index, transition, name);
483 if (!maybe_code->ToObject(&code)) return maybe_code; 501 if (!maybe_code->ToObject(&code)) return maybe_code;
484 } 502 }
485 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, Code::cast(code), name)); 503 PROFILE(isolate_,
504 CodeCreateEvent(Logger::STORE_IC_TAG, Code::cast(code), name));
486 GDBJIT(AddCode(GDBJITInterface::STORE_IC, name, Code::cast(code))); 505 GDBJIT(AddCode(GDBJITInterface::STORE_IC, name, Code::cast(code)));
487 Object* result; 506 Object* result;
488 { MaybeObject* maybe_result = 507 { MaybeObject* maybe_result =
489 receiver->UpdateMapCodeCache(name, Code::cast(code)); 508 receiver->UpdateMapCodeCache(name, Code::cast(code));
490 if (!maybe_result->ToObject(&result)) return maybe_result; 509 if (!maybe_result->ToObject(&result)) return maybe_result;
491 } 510 }
492 } 511 }
493 return code; 512 return code;
494 } 513 }
495 514
496 515
497 MaybeObject* StubCache::ComputeKeyedStoreSpecialized( 516 MaybeObject* StubCache::ComputeKeyedStoreSpecialized(
498 JSObject* receiver, 517 JSObject* receiver,
499 StrictModeFlag strict_mode) { 518 StrictModeFlag strict_mode) {
500 Code::Flags flags = 519 Code::Flags flags =
501 Code::ComputeMonomorphicFlags(Code::KEYED_STORE_IC, NORMAL, strict_mode); 520 Code::ComputeMonomorphicFlags(Code::KEYED_STORE_IC, NORMAL, strict_mode);
502 String* name = Heap::KeyedStoreSpecialized_symbol(); 521 String* name = isolate_->heap()->KeyedStoreSpecialized_symbol();
503 Object* code = receiver->map()->FindInCodeCache(name, flags); 522 Object* code = receiver->map()->FindInCodeCache(name, flags);
504 if (code->IsUndefined()) { 523 if (code->IsUndefined()) {
505 KeyedStoreStubCompiler compiler(strict_mode); 524 KeyedStoreStubCompiler compiler(strict_mode);
506 { MaybeObject* maybe_code = compiler.CompileStoreSpecialized(receiver); 525 { MaybeObject* maybe_code = compiler.CompileStoreSpecialized(receiver);
507 if (!maybe_code->ToObject(&code)) return maybe_code; 526 if (!maybe_code->ToObject(&code)) return maybe_code;
508 } 527 }
509 PROFILE(CodeCreateEvent(Logger::KEYED_STORE_IC_TAG, Code::cast(code), 0)); 528 PROFILE(isolate_,
529 CodeCreateEvent(Logger::KEYED_STORE_IC_TAG, Code::cast(code), 0));
510 Object* result; 530 Object* result;
511 { MaybeObject* maybe_result = 531 { MaybeObject* maybe_result =
512 receiver->UpdateMapCodeCache(name, Code::cast(code)); 532 receiver->UpdateMapCodeCache(name, Code::cast(code));
513 if (!maybe_result->ToObject(&result)) return maybe_result; 533 if (!maybe_result->ToObject(&result)) return maybe_result;
514 } 534 }
515 } 535 }
516 return code; 536 return code;
517 } 537 }
518 538
519 539
(...skipping 21 matching lines...) Expand all
541 UNREACHABLE(); 561 UNREACHABLE();
542 return static_cast<ExternalArrayType>(0); 562 return static_cast<ExternalArrayType>(0);
543 } 563 }
544 } 564 }
545 565
546 String* ExternalArrayTypeToStubName(ExternalArrayType array_type, 566 String* ExternalArrayTypeToStubName(ExternalArrayType array_type,
547 bool is_store) { 567 bool is_store) {
548 if (is_store) { 568 if (is_store) {
549 switch (array_type) { 569 switch (array_type) {
550 case kExternalByteArray: 570 case kExternalByteArray:
551 return Heap::KeyedStoreExternalByteArray_symbol(); 571 return HEAP->KeyedStoreExternalByteArray_symbol();
552 case kExternalUnsignedByteArray: 572 case kExternalUnsignedByteArray:
553 return Heap::KeyedStoreExternalUnsignedByteArray_symbol(); 573 return HEAP->KeyedStoreExternalUnsignedByteArray_symbol();
554 case kExternalShortArray: 574 case kExternalShortArray:
555 return Heap::KeyedStoreExternalShortArray_symbol(); 575 return HEAP->KeyedStoreExternalShortArray_symbol();
556 case kExternalUnsignedShortArray: 576 case kExternalUnsignedShortArray:
557 return Heap::KeyedStoreExternalUnsignedShortArray_symbol(); 577 return HEAP->KeyedStoreExternalUnsignedShortArray_symbol();
558 case kExternalIntArray: 578 case kExternalIntArray:
559 return Heap::KeyedStoreExternalIntArray_symbol(); 579 return HEAP->KeyedStoreExternalIntArray_symbol();
560 case kExternalUnsignedIntArray: 580 case kExternalUnsignedIntArray:
561 return Heap::KeyedStoreExternalUnsignedIntArray_symbol(); 581 return HEAP->KeyedStoreExternalUnsignedIntArray_symbol();
562 case kExternalFloatArray: 582 case kExternalFloatArray:
563 return Heap::KeyedStoreExternalFloatArray_symbol(); 583 return HEAP->KeyedStoreExternalFloatArray_symbol();
564 case kExternalPixelArray: 584 case kExternalPixelArray:
565 return Heap::KeyedStoreExternalPixelArray_symbol(); 585 return HEAP->KeyedStoreExternalPixelArray_symbol();
566 default: 586 default:
567 UNREACHABLE(); 587 UNREACHABLE();
568 return NULL; 588 return NULL;
569 } 589 }
570 } else { 590 } else {
571 switch (array_type) { 591 switch (array_type) {
572 case kExternalByteArray: 592 case kExternalByteArray:
573 return Heap::KeyedLoadExternalByteArray_symbol(); 593 return HEAP->KeyedLoadExternalByteArray_symbol();
574 case kExternalUnsignedByteArray: 594 case kExternalUnsignedByteArray:
575 return Heap::KeyedLoadExternalUnsignedByteArray_symbol(); 595 return HEAP->KeyedLoadExternalUnsignedByteArray_symbol();
576 case kExternalShortArray: 596 case kExternalShortArray:
577 return Heap::KeyedLoadExternalShortArray_symbol(); 597 return HEAP->KeyedLoadExternalShortArray_symbol();
578 case kExternalUnsignedShortArray: 598 case kExternalUnsignedShortArray:
579 return Heap::KeyedLoadExternalUnsignedShortArray_symbol(); 599 return HEAP->KeyedLoadExternalUnsignedShortArray_symbol();
580 case kExternalIntArray: 600 case kExternalIntArray:
581 return Heap::KeyedLoadExternalIntArray_symbol(); 601 return HEAP->KeyedLoadExternalIntArray_symbol();
582 case kExternalUnsignedIntArray: 602 case kExternalUnsignedIntArray:
583 return Heap::KeyedLoadExternalUnsignedIntArray_symbol(); 603 return HEAP->KeyedLoadExternalUnsignedIntArray_symbol();
584 case kExternalFloatArray: 604 case kExternalFloatArray:
585 return Heap::KeyedLoadExternalFloatArray_symbol(); 605 return HEAP->KeyedLoadExternalFloatArray_symbol();
586 case kExternalPixelArray: 606 case kExternalPixelArray:
587 return Heap::KeyedLoadExternalPixelArray_symbol(); 607 return HEAP->KeyedLoadExternalPixelArray_symbol();
588 default: 608 default:
589 UNREACHABLE(); 609 UNREACHABLE();
590 return NULL; 610 return NULL;
591 } 611 }
592 } 612 }
593 } 613 }
594 614
595 } // anonymous namespace 615 } // anonymous namespace
596 616
597 617
(...skipping 14 matching lines...) Expand all
612 if (code->IsUndefined()) { 632 if (code->IsUndefined()) {
613 ExternalArrayStubCompiler compiler; 633 ExternalArrayStubCompiler compiler;
614 { MaybeObject* maybe_code = 634 { MaybeObject* maybe_code =
615 is_store ? 635 is_store ?
616 compiler.CompileKeyedStoreStub(receiver, array_type, flags) : 636 compiler.CompileKeyedStoreStub(receiver, array_type, flags) :
617 compiler.CompileKeyedLoadStub(receiver, array_type, flags); 637 compiler.CompileKeyedLoadStub(receiver, array_type, flags);
618 if (!maybe_code->ToObject(&code)) return maybe_code; 638 if (!maybe_code->ToObject(&code)) return maybe_code;
619 } 639 }
620 Code::cast(code)->set_external_array_type(array_type); 640 Code::cast(code)->set_external_array_type(array_type);
621 if (is_store) { 641 if (is_store) {
622 PROFILE( 642 PROFILE(isolate_,
623 CodeCreateEvent(Logger::KEYED_EXTERNAL_ARRAY_STORE_IC_TAG, 643 CodeCreateEvent(Logger::KEYED_EXTERNAL_ARRAY_STORE_IC_TAG,
624 Code::cast(code), 0)); 644 Code::cast(code), 0));
625 } else { 645 } else {
626 PROFILE( 646 PROFILE(isolate_,
627 CodeCreateEvent(Logger::KEYED_EXTERNAL_ARRAY_LOAD_IC_TAG, 647 CodeCreateEvent(Logger::KEYED_EXTERNAL_ARRAY_LOAD_IC_TAG,
628 Code::cast(code), 0)); 648 Code::cast(code), 0));
629 } 649 }
630 Object* result; 650 Object* result;
631 { MaybeObject* maybe_result = 651 { MaybeObject* maybe_result =
632 receiver->map()->UpdateCodeCache(name, Code::cast(code)); 652 receiver->map()->UpdateCodeCache(name, Code::cast(code));
633 if (!maybe_result->ToObject(&result)) return maybe_result; 653 if (!maybe_result->ToObject(&result)) return maybe_result;
634 } 654 }
635 } 655 }
636 return code; 656 return code;
637 } 657 }
638 658
639 659
640 MaybeObject* StubCache::ComputeStoreNormal(StrictModeFlag strict_mode) { 660 MaybeObject* StubCache::ComputeStoreNormal(StrictModeFlag strict_mode) {
641 return Builtins::builtin((strict_mode == kStrictMode) 661 return isolate_->builtins()->builtin((strict_mode == kStrictMode)
642 ? Builtins::StoreIC_Normal_Strict 662 ? Builtins::StoreIC_Normal_Strict
643 : Builtins::StoreIC_Normal); 663 : Builtins::StoreIC_Normal);
644 } 664 }
645 665
646 666
647 MaybeObject* StubCache::ComputeStoreGlobal(String* name, 667 MaybeObject* StubCache::ComputeStoreGlobal(String* name,
648 GlobalObject* receiver, 668 GlobalObject* receiver,
649 JSGlobalPropertyCell* cell, 669 JSGlobalPropertyCell* cell,
650 StrictModeFlag strict_mode) { 670 StrictModeFlag strict_mode) {
651 Code::Flags flags = Code::ComputeMonomorphicFlags( 671 Code::Flags flags = Code::ComputeMonomorphicFlags(
652 Code::STORE_IC, NORMAL, strict_mode); 672 Code::STORE_IC, NORMAL, strict_mode);
653 Object* code = receiver->map()->FindInCodeCache(name, flags); 673 Object* code = receiver->map()->FindInCodeCache(name, flags);
654 if (code->IsUndefined()) { 674 if (code->IsUndefined()) {
655 StoreStubCompiler compiler(strict_mode); 675 StoreStubCompiler compiler(strict_mode);
656 { MaybeObject* maybe_code = 676 { MaybeObject* maybe_code =
657 compiler.CompileStoreGlobal(receiver, cell, name); 677 compiler.CompileStoreGlobal(receiver, cell, name);
658 if (!maybe_code->ToObject(&code)) return maybe_code; 678 if (!maybe_code->ToObject(&code)) return maybe_code;
659 } 679 }
660 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, Code::cast(code), name)); 680 PROFILE(isolate_,
681 CodeCreateEvent(Logger::STORE_IC_TAG, Code::cast(code), name));
661 GDBJIT(AddCode(GDBJITInterface::STORE_IC, name, Code::cast(code))); 682 GDBJIT(AddCode(GDBJITInterface::STORE_IC, name, Code::cast(code)));
662 Object* result; 683 Object* result;
663 { MaybeObject* maybe_result = 684 { MaybeObject* maybe_result =
664 receiver->UpdateMapCodeCache(name, Code::cast(code)); 685 receiver->UpdateMapCodeCache(name, Code::cast(code));
665 if (!maybe_result->ToObject(&result)) return maybe_result; 686 if (!maybe_result->ToObject(&result)) return maybe_result;
666 } 687 }
667 } 688 }
668 return code; 689 return code;
669 } 690 }
670 691
671 692
672 MaybeObject* StubCache::ComputeStoreCallback( 693 MaybeObject* StubCache::ComputeStoreCallback(
673 String* name, 694 String* name,
674 JSObject* receiver, 695 JSObject* receiver,
675 AccessorInfo* callback, 696 AccessorInfo* callback,
676 StrictModeFlag strict_mode) { 697 StrictModeFlag strict_mode) {
677 ASSERT(v8::ToCData<Address>(callback->setter()) != 0); 698 ASSERT(v8::ToCData<Address>(callback->setter()) != 0);
678 Code::Flags flags = Code::ComputeMonomorphicFlags( 699 Code::Flags flags = Code::ComputeMonomorphicFlags(
679 Code::STORE_IC, CALLBACKS, strict_mode); 700 Code::STORE_IC, CALLBACKS, strict_mode);
680 Object* code = receiver->map()->FindInCodeCache(name, flags); 701 Object* code = receiver->map()->FindInCodeCache(name, flags);
681 if (code->IsUndefined()) { 702 if (code->IsUndefined()) {
682 StoreStubCompiler compiler(strict_mode); 703 StoreStubCompiler compiler(strict_mode);
683 { MaybeObject* maybe_code = 704 { MaybeObject* maybe_code =
684 compiler.CompileStoreCallback(receiver, callback, name); 705 compiler.CompileStoreCallback(receiver, callback, name);
685 if (!maybe_code->ToObject(&code)) return maybe_code; 706 if (!maybe_code->ToObject(&code)) return maybe_code;
686 } 707 }
687 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, Code::cast(code), name)); 708 PROFILE(isolate_,
709 CodeCreateEvent(Logger::STORE_IC_TAG, Code::cast(code), name));
688 GDBJIT(AddCode(GDBJITInterface::STORE_IC, name, Code::cast(code))); 710 GDBJIT(AddCode(GDBJITInterface::STORE_IC, name, Code::cast(code)));
689 Object* result; 711 Object* result;
690 { MaybeObject* maybe_result = 712 { MaybeObject* maybe_result =
691 receiver->UpdateMapCodeCache(name, Code::cast(code)); 713 receiver->UpdateMapCodeCache(name, Code::cast(code));
692 if (!maybe_result->ToObject(&result)) return maybe_result; 714 if (!maybe_result->ToObject(&result)) return maybe_result;
693 } 715 }
694 } 716 }
695 return code; 717 return code;
696 } 718 }
697 719
698 720
699 MaybeObject* StubCache::ComputeStoreInterceptor( 721 MaybeObject* StubCache::ComputeStoreInterceptor(
700 String* name, 722 String* name,
701 JSObject* receiver, 723 JSObject* receiver,
702 StrictModeFlag strict_mode) { 724 StrictModeFlag strict_mode) {
703 Code::Flags flags = Code::ComputeMonomorphicFlags( 725 Code::Flags flags = Code::ComputeMonomorphicFlags(
704 Code::STORE_IC, INTERCEPTOR, strict_mode); 726 Code::STORE_IC, INTERCEPTOR, strict_mode);
705 Object* code = receiver->map()->FindInCodeCache(name, flags); 727 Object* code = receiver->map()->FindInCodeCache(name, flags);
706 if (code->IsUndefined()) { 728 if (code->IsUndefined()) {
707 StoreStubCompiler compiler(strict_mode); 729 StoreStubCompiler compiler(strict_mode);
708 { MaybeObject* maybe_code = 730 { MaybeObject* maybe_code =
709 compiler.CompileStoreInterceptor(receiver, name); 731 compiler.CompileStoreInterceptor(receiver, name);
710 if (!maybe_code->ToObject(&code)) return maybe_code; 732 if (!maybe_code->ToObject(&code)) return maybe_code;
711 } 733 }
712 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, Code::cast(code), name)); 734 PROFILE(isolate_,
735 CodeCreateEvent(Logger::STORE_IC_TAG, Code::cast(code), name));
713 GDBJIT(AddCode(GDBJITInterface::STORE_IC, name, Code::cast(code))); 736 GDBJIT(AddCode(GDBJITInterface::STORE_IC, name, Code::cast(code)));
714 Object* result; 737 Object* result;
715 { MaybeObject* maybe_result = 738 { MaybeObject* maybe_result =
716 receiver->UpdateMapCodeCache(name, Code::cast(code)); 739 receiver->UpdateMapCodeCache(name, Code::cast(code));
717 if (!maybe_result->ToObject(&result)) return maybe_result; 740 if (!maybe_result->ToObject(&result)) return maybe_result;
718 } 741 }
719 } 742 }
720 return code; 743 return code;
721 } 744 }
722 745
723 746
724 MaybeObject* StubCache::ComputeKeyedStoreField(String* name, 747 MaybeObject* StubCache::ComputeKeyedStoreField(String* name,
725 JSObject* receiver, 748 JSObject* receiver,
726 int field_index, 749 int field_index,
727 Map* transition, 750 Map* transition,
728 StrictModeFlag strict_mode) { 751 StrictModeFlag strict_mode) {
729 PropertyType type = (transition == NULL) ? FIELD : MAP_TRANSITION; 752 PropertyType type = (transition == NULL) ? FIELD : MAP_TRANSITION;
730 Code::Flags flags = Code::ComputeMonomorphicFlags( 753 Code::Flags flags = Code::ComputeMonomorphicFlags(
731 Code::KEYED_STORE_IC, type, strict_mode); 754 Code::KEYED_STORE_IC, type, strict_mode);
732 Object* code = receiver->map()->FindInCodeCache(name, flags); 755 Object* code = receiver->map()->FindInCodeCache(name, flags);
733 if (code->IsUndefined()) { 756 if (code->IsUndefined()) {
734 KeyedStoreStubCompiler compiler(strict_mode); 757 KeyedStoreStubCompiler compiler(strict_mode);
735 { MaybeObject* maybe_code = 758 { MaybeObject* maybe_code =
736 compiler.CompileStoreField(receiver, field_index, transition, name); 759 compiler.CompileStoreField(receiver, field_index, transition, name);
737 if (!maybe_code->ToObject(&code)) return maybe_code; 760 if (!maybe_code->ToObject(&code)) return maybe_code;
738 } 761 }
739 PROFILE(CodeCreateEvent( 762 PROFILE(isolate_,
740 Logger::KEYED_STORE_IC_TAG, Code::cast(code), name)); 763 CodeCreateEvent(Logger::KEYED_STORE_IC_TAG,
764 Code::cast(code), name));
741 GDBJIT(AddCode(GDBJITInterface::KEYED_STORE_IC, name, Code::cast(code))); 765 GDBJIT(AddCode(GDBJITInterface::KEYED_STORE_IC, name, Code::cast(code)));
742 Object* result; 766 Object* result;
743 { MaybeObject* maybe_result = 767 { MaybeObject* maybe_result =
744 receiver->UpdateMapCodeCache(name, Code::cast(code)); 768 receiver->UpdateMapCodeCache(name, Code::cast(code));
745 if (!maybe_result->ToObject(&result)) return maybe_result; 769 if (!maybe_result->ToObject(&result)) return maybe_result;
746 } 770 }
747 } 771 }
748 return code; 772 return code;
749 } 773 }
750 774
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 if (!function->is_compiled()) return Failure::InternalError(); 813 if (!function->is_compiled()) return Failure::InternalError();
790 // Compile the stub - only create stubs for fully compiled functions. 814 // Compile the stub - only create stubs for fully compiled functions.
791 CallStubCompiler compiler( 815 CallStubCompiler compiler(
792 argc, in_loop, kind, extra_ic_state, cache_holder); 816 argc, in_loop, kind, extra_ic_state, cache_holder);
793 { MaybeObject* maybe_code = 817 { MaybeObject* maybe_code =
794 compiler.CompileCallConstant(object, holder, function, name, check); 818 compiler.CompileCallConstant(object, holder, function, name, check);
795 if (!maybe_code->ToObject(&code)) return maybe_code; 819 if (!maybe_code->ToObject(&code)) return maybe_code;
796 } 820 }
797 Code::cast(code)->set_check_type(check); 821 Code::cast(code)->set_check_type(check);
798 ASSERT_EQ(flags, Code::cast(code)->flags()); 822 ASSERT_EQ(flags, Code::cast(code)->flags());
799 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), 823 PROFILE(isolate_,
824 CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG),
800 Code::cast(code), name)); 825 Code::cast(code), name));
801 GDBJIT(AddCode(GDBJITInterface::CALL_IC, name, Code::cast(code))); 826 GDBJIT(AddCode(GDBJITInterface::CALL_IC, name, Code::cast(code)));
802 Object* result; 827 Object* result;
803 { MaybeObject* maybe_result = 828 { MaybeObject* maybe_result =
804 map_holder->UpdateMapCodeCache(name, Code::cast(code)); 829 map_holder->UpdateMapCodeCache(name, Code::cast(code));
805 if (!maybe_result->ToObject(&result)) return maybe_result; 830 if (!maybe_result->ToObject(&result)) return maybe_result;
806 } 831 }
807 } 832 }
808 return code; 833 return code;
809 } 834 }
(...skipping 29 matching lines...) Expand all
839 CallStubCompiler compiler( 864 CallStubCompiler compiler(
840 argc, in_loop, kind, Code::kNoExtraICState, cache_holder); 865 argc, in_loop, kind, Code::kNoExtraICState, cache_holder);
841 { MaybeObject* maybe_code = 866 { MaybeObject* maybe_code =
842 compiler.CompileCallField(JSObject::cast(object), 867 compiler.CompileCallField(JSObject::cast(object),
843 holder, 868 holder,
844 index, 869 index,
845 name); 870 name);
846 if (!maybe_code->ToObject(&code)) return maybe_code; 871 if (!maybe_code->ToObject(&code)) return maybe_code;
847 } 872 }
848 ASSERT_EQ(flags, Code::cast(code)->flags()); 873 ASSERT_EQ(flags, Code::cast(code)->flags());
849 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), 874 PROFILE(isolate_,
875 CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG),
850 Code::cast(code), name)); 876 Code::cast(code), name));
851 GDBJIT(AddCode(GDBJITInterface::CALL_IC, name, Code::cast(code))); 877 GDBJIT(AddCode(GDBJITInterface::CALL_IC, name, Code::cast(code)));
852 Object* result; 878 Object* result;
853 { MaybeObject* maybe_result = 879 { MaybeObject* maybe_result =
854 map_holder->UpdateMapCodeCache(name, Code::cast(code)); 880 map_holder->UpdateMapCodeCache(name, Code::cast(code));
855 if (!maybe_result->ToObject(&result)) return maybe_result; 881 if (!maybe_result->ToObject(&result)) return maybe_result;
856 } 882 }
857 } 883 }
858 return code; 884 return code;
859 } 885 }
(...skipping 24 matching lines...) Expand all
884 argc); 910 argc);
885 Object* code = map_holder->map()->FindInCodeCache(name, flags); 911 Object* code = map_holder->map()->FindInCodeCache(name, flags);
886 if (code->IsUndefined()) { 912 if (code->IsUndefined()) {
887 CallStubCompiler compiler( 913 CallStubCompiler compiler(
888 argc, NOT_IN_LOOP, kind, Code::kNoExtraICState, cache_holder); 914 argc, NOT_IN_LOOP, kind, Code::kNoExtraICState, cache_holder);
889 { MaybeObject* maybe_code = 915 { MaybeObject* maybe_code =
890 compiler.CompileCallInterceptor(JSObject::cast(object), holder, name); 916 compiler.CompileCallInterceptor(JSObject::cast(object), holder, name);
891 if (!maybe_code->ToObject(&code)) return maybe_code; 917 if (!maybe_code->ToObject(&code)) return maybe_code;
892 } 918 }
893 ASSERT_EQ(flags, Code::cast(code)->flags()); 919 ASSERT_EQ(flags, Code::cast(code)->flags());
894 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), 920 PROFILE(isolate_,
921 CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG),
895 Code::cast(code), name)); 922 Code::cast(code), name));
896 GDBJIT(AddCode(GDBJITInterface::CALL_IC, name, Code::cast(code))); 923 GDBJIT(AddCode(GDBJITInterface::CALL_IC, name, Code::cast(code)));
897 Object* result; 924 Object* result;
898 { MaybeObject* maybe_result = 925 { MaybeObject* maybe_result =
899 map_holder->UpdateMapCodeCache(name, Code::cast(code)); 926 map_holder->UpdateMapCodeCache(name, Code::cast(code));
900 if (!maybe_result->ToObject(&result)) return maybe_result; 927 if (!maybe_result->ToObject(&result)) return maybe_result;
901 } 928 }
902 } 929 }
903 return code; 930 return code;
904 } 931 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 // internal error which will make sure we do not update any 968 // internal error which will make sure we do not update any
942 // caches. 969 // caches.
943 if (!function->is_compiled()) return Failure::InternalError(); 970 if (!function->is_compiled()) return Failure::InternalError();
944 CallStubCompiler compiler( 971 CallStubCompiler compiler(
945 argc, in_loop, kind, Code::kNoExtraICState, cache_holder); 972 argc, in_loop, kind, Code::kNoExtraICState, cache_holder);
946 { MaybeObject* maybe_code = 973 { MaybeObject* maybe_code =
947 compiler.CompileCallGlobal(receiver, holder, cell, function, name); 974 compiler.CompileCallGlobal(receiver, holder, cell, function, name);
948 if (!maybe_code->ToObject(&code)) return maybe_code; 975 if (!maybe_code->ToObject(&code)) return maybe_code;
949 } 976 }
950 ASSERT_EQ(flags, Code::cast(code)->flags()); 977 ASSERT_EQ(flags, Code::cast(code)->flags());
951 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), 978 PROFILE(isolate_,
979 CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG),
952 Code::cast(code), name)); 980 Code::cast(code), name));
953 GDBJIT(AddCode(GDBJITInterface::CALL_IC, name, Code::cast(code))); 981 GDBJIT(AddCode(GDBJITInterface::CALL_IC, name, Code::cast(code)));
954 Object* result; 982 Object* result;
955 { MaybeObject* maybe_result = 983 { MaybeObject* maybe_result =
956 map_holder->UpdateMapCodeCache(name, Code::cast(code)); 984 map_holder->UpdateMapCodeCache(name, Code::cast(code));
957 if (!maybe_result->ToObject(&result)) return maybe_result; 985 if (!maybe_result->ToObject(&result)) return maybe_result;
958 } 986 }
959 } 987 }
960 return code; 988 return code;
961 } 989 }
962 990
963 991
964 static Object* GetProbeValue(Code::Flags flags) { 992 static Object* GetProbeValue(Isolate* isolate, Code::Flags flags) {
965 // Use raw_unchecked... so we don't get assert failures during GC. 993 // Use raw_unchecked... so we don't get assert failures during GC.
966 NumberDictionary* dictionary = Heap::raw_unchecked_non_monomorphic_cache(); 994 NumberDictionary* dictionary =
967 int entry = dictionary->FindEntry(flags); 995 isolate->heap()->raw_unchecked_non_monomorphic_cache();
996 int entry = dictionary->FindEntry(isolate, flags);
968 if (entry != -1) return dictionary->ValueAt(entry); 997 if (entry != -1) return dictionary->ValueAt(entry);
969 return Heap::raw_unchecked_undefined_value(); 998 return isolate->heap()->raw_unchecked_undefined_value();
970 } 999 }
971 1000
972 1001
973 MUST_USE_RESULT static MaybeObject* ProbeCache(Code::Flags flags) { 1002 MUST_USE_RESULT static MaybeObject* ProbeCache(Isolate* isolate,
974 Object* probe = GetProbeValue(flags); 1003 Code::Flags flags) {
975 if (probe != Heap::undefined_value()) return probe; 1004 Heap* heap = isolate->heap();
1005 Object* probe = GetProbeValue(isolate, flags);
1006 if (probe != heap->undefined_value()) return probe;
976 // Seed the cache with an undefined value to make sure that any 1007 // Seed the cache with an undefined value to make sure that any
977 // generated code object can always be inserted into the cache 1008 // generated code object can always be inserted into the cache
978 // without causing allocation failures. 1009 // without causing allocation failures.
979 Object* result; 1010 Object* result;
980 { MaybeObject* maybe_result = 1011 { MaybeObject* maybe_result =
981 Heap::non_monomorphic_cache()->AtNumberPut(flags, 1012 heap->non_monomorphic_cache()->AtNumberPut(flags,
982 Heap::undefined_value()); 1013 heap->undefined_value());
983 if (!maybe_result->ToObject(&result)) return maybe_result; 1014 if (!maybe_result->ToObject(&result)) return maybe_result;
984 } 1015 }
985 Heap::public_set_non_monomorphic_cache(NumberDictionary::cast(result)); 1016 heap->public_set_non_monomorphic_cache(NumberDictionary::cast(result));
986 return probe; 1017 return probe;
987 } 1018 }
988 1019
989 1020
990 static MaybeObject* FillCache(MaybeObject* maybe_code) { 1021 static MaybeObject* FillCache(Isolate* isolate, MaybeObject* maybe_code) {
991 Object* code; 1022 Object* code;
992 if (maybe_code->ToObject(&code)) { 1023 if (maybe_code->ToObject(&code)) {
993 if (code->IsCode()) { 1024 if (code->IsCode()) {
994 int entry = 1025 Heap* heap = isolate->heap();
995 Heap::non_monomorphic_cache()->FindEntry( 1026 int entry = heap->non_monomorphic_cache()->FindEntry(
996 Code::cast(code)->flags()); 1027 Code::cast(code)->flags());
997 // The entry must be present see comment in ProbeCache. 1028 // The entry must be present see comment in ProbeCache.
998 ASSERT(entry != -1); 1029 ASSERT(entry != -1);
999 ASSERT(Heap::non_monomorphic_cache()->ValueAt(entry) == 1030 ASSERT(heap->non_monomorphic_cache()->ValueAt(entry) ==
1000 Heap::undefined_value()); 1031 heap->undefined_value());
1001 Heap::non_monomorphic_cache()->ValueAtPut(entry, code); 1032 heap->non_monomorphic_cache()->ValueAtPut(entry, code);
1002 CHECK(GetProbeValue(Code::cast(code)->flags()) == code); 1033 CHECK(GetProbeValue(isolate, Code::cast(code)->flags()) == code);
1003 } 1034 }
1004 } 1035 }
1005 return maybe_code; 1036 return maybe_code;
1006 } 1037 }
1007 1038
1008 1039
1009 Code* StubCache::FindCallInitialize(int argc, 1040 Code* StubCache::FindCallInitialize(int argc,
1010 InLoopFlag in_loop, 1041 InLoopFlag in_loop,
1011 Code::Kind kind) { 1042 Code::Kind kind) {
1012 Code::Flags flags = Code::ComputeFlags(kind, 1043 Code::Flags flags = Code::ComputeFlags(kind,
1013 in_loop, 1044 in_loop,
1014 UNINITIALIZED, 1045 UNINITIALIZED,
1015 Code::kNoExtraICState, 1046 Code::kNoExtraICState,
1016 NORMAL, 1047 NORMAL,
1017 argc); 1048 argc);
1018 Object* result = ProbeCache(flags)->ToObjectUnchecked(); 1049 Object* result = ProbeCache(isolate_, flags)->ToObjectUnchecked();
1019 ASSERT(!result->IsUndefined()); 1050 ASSERT(result != isolate_->heap()->undefined_value());
1020 // This might be called during the marking phase of the collector 1051 // This might be called during the marking phase of the collector
1021 // hence the unchecked cast. 1052 // hence the unchecked cast.
1022 return reinterpret_cast<Code*>(result); 1053 return reinterpret_cast<Code*>(result);
1023 } 1054 }
1024 1055
1025 1056
1026 MaybeObject* StubCache::ComputeCallInitialize(int argc, 1057 MaybeObject* StubCache::ComputeCallInitialize(int argc,
1027 InLoopFlag in_loop, 1058 InLoopFlag in_loop,
1028 Code::Kind kind) { 1059 Code::Kind kind) {
1029 Code::Flags flags = Code::ComputeFlags(kind, 1060 Code::Flags flags = Code::ComputeFlags(kind,
1030 in_loop, 1061 in_loop,
1031 UNINITIALIZED, 1062 UNINITIALIZED,
1032 Code::kNoExtraICState, 1063 Code::kNoExtraICState,
1033 NORMAL, 1064 NORMAL,
1034 argc); 1065 argc);
1035 Object* probe; 1066 Object* probe;
1036 { MaybeObject* maybe_probe = ProbeCache(flags); 1067 { MaybeObject* maybe_probe = ProbeCache(isolate_, flags);
1037 if (!maybe_probe->ToObject(&probe)) return maybe_probe; 1068 if (!maybe_probe->ToObject(&probe)) return maybe_probe;
1038 } 1069 }
1039 if (!probe->IsUndefined()) return probe; 1070 if (!probe->IsUndefined()) return probe;
1040 StubCompiler compiler; 1071 StubCompiler compiler;
1041 return FillCache(compiler.CompileCallInitialize(flags)); 1072 return FillCache(isolate_, compiler.CompileCallInitialize(flags));
1042 } 1073 }
1043 1074
1044 1075
1045 Handle<Code> StubCache::ComputeCallInitialize(int argc, InLoopFlag in_loop) { 1076 Handle<Code> StubCache::ComputeCallInitialize(int argc, InLoopFlag in_loop) {
1046 if (in_loop == IN_LOOP) { 1077 if (in_loop == IN_LOOP) {
1047 // Force the creation of the corresponding stub outside loops, 1078 // Force the creation of the corresponding stub outside loops,
1048 // because it may be used when clearing the ICs later - it is 1079 // because it may be used when clearing the ICs later - it is
1049 // possible for a series of IC transitions to lose the in-loop 1080 // possible for a series of IC transitions to lose the in-loop
1050 // information, and the IC clearing code can't generate a stub 1081 // information, and the IC clearing code can't generate a stub
1051 // that it needs so we need to ensure it is generated already. 1082 // that it needs so we need to ensure it is generated already.
1052 ComputeCallInitialize(argc, NOT_IN_LOOP); 1083 ComputeCallInitialize(argc, NOT_IN_LOOP);
1053 } 1084 }
1054 CALL_HEAP_FUNCTION(ComputeCallInitialize(argc, in_loop, Code::CALL_IC), Code); 1085 CALL_HEAP_FUNCTION(isolate_,
1086 ComputeCallInitialize(argc, in_loop, Code::CALL_IC), Code);
1055 } 1087 }
1056 1088
1057 1089
1058 Handle<Code> StubCache::ComputeKeyedCallInitialize(int argc, 1090 Handle<Code> StubCache::ComputeKeyedCallInitialize(int argc,
1059 InLoopFlag in_loop) { 1091 InLoopFlag in_loop) {
1060 if (in_loop == IN_LOOP) { 1092 if (in_loop == IN_LOOP) {
1061 // Force the creation of the corresponding stub outside loops, 1093 // Force the creation of the corresponding stub outside loops,
1062 // because it may be used when clearing the ICs later - it is 1094 // because it may be used when clearing the ICs later - it is
1063 // possible for a series of IC transitions to lose the in-loop 1095 // possible for a series of IC transitions to lose the in-loop
1064 // information, and the IC clearing code can't generate a stub 1096 // information, and the IC clearing code can't generate a stub
1065 // that it needs so we need to ensure it is generated already. 1097 // that it needs so we need to ensure it is generated already.
1066 ComputeKeyedCallInitialize(argc, NOT_IN_LOOP); 1098 ComputeKeyedCallInitialize(argc, NOT_IN_LOOP);
1067 } 1099 }
1068 CALL_HEAP_FUNCTION( 1100 CALL_HEAP_FUNCTION(
1101 isolate_,
1069 ComputeCallInitialize(argc, in_loop, Code::KEYED_CALL_IC), Code); 1102 ComputeCallInitialize(argc, in_loop, Code::KEYED_CALL_IC), Code);
1070 } 1103 }
1071 1104
1072 1105
1073 MaybeObject* StubCache::ComputeCallPreMonomorphic(int argc, 1106 MaybeObject* StubCache::ComputeCallPreMonomorphic(int argc,
1074 InLoopFlag in_loop, 1107 InLoopFlag in_loop,
1075 Code::Kind kind) { 1108 Code::Kind kind) {
1076 Code::Flags flags = Code::ComputeFlags(kind, 1109 Code::Flags flags = Code::ComputeFlags(kind,
1077 in_loop, 1110 in_loop,
1078 PREMONOMORPHIC, 1111 PREMONOMORPHIC,
1079 Code::kNoExtraICState, 1112 Code::kNoExtraICState,
1080 NORMAL, 1113 NORMAL,
1081 argc); 1114 argc);
1082 Object* probe; 1115 Object* probe;
1083 { MaybeObject* maybe_probe = ProbeCache(flags); 1116 { MaybeObject* maybe_probe = ProbeCache(isolate_, flags);
1084 if (!maybe_probe->ToObject(&probe)) return maybe_probe; 1117 if (!maybe_probe->ToObject(&probe)) return maybe_probe;
1085 } 1118 }
1086 if (!probe->IsUndefined()) return probe; 1119 if (!probe->IsUndefined()) return probe;
1087 StubCompiler compiler; 1120 StubCompiler compiler;
1088 return FillCache(compiler.CompileCallPreMonomorphic(flags)); 1121 return FillCache(isolate_, compiler.CompileCallPreMonomorphic(flags));
1089 } 1122 }
1090 1123
1091 1124
1092 MaybeObject* StubCache::ComputeCallNormal(int argc, 1125 MaybeObject* StubCache::ComputeCallNormal(int argc,
1093 InLoopFlag in_loop, 1126 InLoopFlag in_loop,
1094 Code::Kind kind) { 1127 Code::Kind kind) {
1095 Code::Flags flags = Code::ComputeFlags(kind, 1128 Code::Flags flags = Code::ComputeFlags(kind,
1096 in_loop, 1129 in_loop,
1097 MONOMORPHIC, 1130 MONOMORPHIC,
1098 Code::kNoExtraICState, 1131 Code::kNoExtraICState,
1099 NORMAL, 1132 NORMAL,
1100 argc); 1133 argc);
1101 Object* probe; 1134 Object* probe;
1102 { MaybeObject* maybe_probe = ProbeCache(flags); 1135 { MaybeObject* maybe_probe = ProbeCache(isolate_, flags);
1103 if (!maybe_probe->ToObject(&probe)) return maybe_probe; 1136 if (!maybe_probe->ToObject(&probe)) return maybe_probe;
1104 } 1137 }
1105 if (!probe->IsUndefined()) return probe; 1138 if (!probe->IsUndefined()) return probe;
1106 StubCompiler compiler; 1139 StubCompiler compiler;
1107 return FillCache(compiler.CompileCallNormal(flags)); 1140 return FillCache(isolate_, compiler.CompileCallNormal(flags));
1108 } 1141 }
1109 1142
1110 1143
1111 MaybeObject* StubCache::ComputeCallMegamorphic(int argc, 1144 MaybeObject* StubCache::ComputeCallMegamorphic(int argc,
1112 InLoopFlag in_loop, 1145 InLoopFlag in_loop,
1113 Code::Kind kind) { 1146 Code::Kind kind) {
1114 Code::Flags flags = Code::ComputeFlags(kind, 1147 Code::Flags flags = Code::ComputeFlags(kind,
1115 in_loop, 1148 in_loop,
1116 MEGAMORPHIC, 1149 MEGAMORPHIC,
1117 Code::kNoExtraICState, 1150 Code::kNoExtraICState,
1118 NORMAL, 1151 NORMAL,
1119 argc); 1152 argc);
1120 Object* probe; 1153 Object* probe;
1121 { MaybeObject* maybe_probe = ProbeCache(flags); 1154 { MaybeObject* maybe_probe = ProbeCache(isolate_, flags);
1122 if (!maybe_probe->ToObject(&probe)) return maybe_probe; 1155 if (!maybe_probe->ToObject(&probe)) return maybe_probe;
1123 } 1156 }
1124 if (!probe->IsUndefined()) return probe; 1157 if (!probe->IsUndefined()) return probe;
1125 StubCompiler compiler; 1158 StubCompiler compiler;
1126 return FillCache(compiler.CompileCallMegamorphic(flags)); 1159 return FillCache(isolate_, compiler.CompileCallMegamorphic(flags));
1127 } 1160 }
1128 1161
1129 1162
1130 MaybeObject* StubCache::ComputeCallMiss(int argc, Code::Kind kind) { 1163 MaybeObject* StubCache::ComputeCallMiss(int argc, Code::Kind kind) {
1131 // MONOMORPHIC_PROTOTYPE_FAILURE state is used to make sure that miss stubs 1164 // MONOMORPHIC_PROTOTYPE_FAILURE state is used to make sure that miss stubs
1132 // and monomorphic stubs are not mixed up together in the stub cache. 1165 // and monomorphic stubs are not mixed up together in the stub cache.
1133 Code::Flags flags = Code::ComputeFlags(kind, 1166 Code::Flags flags = Code::ComputeFlags(kind,
1134 NOT_IN_LOOP, 1167 NOT_IN_LOOP,
1135 MONOMORPHIC_PROTOTYPE_FAILURE, 1168 MONOMORPHIC_PROTOTYPE_FAILURE,
1136 Code::kNoExtraICState, 1169 Code::kNoExtraICState,
1137 NORMAL, 1170 NORMAL,
1138 argc, 1171 argc,
1139 OWN_MAP); 1172 OWN_MAP);
1140 Object* probe; 1173 Object* probe;
1141 { MaybeObject* maybe_probe = ProbeCache(flags); 1174 { MaybeObject* maybe_probe = ProbeCache(isolate_, flags);
1142 if (!maybe_probe->ToObject(&probe)) return maybe_probe; 1175 if (!maybe_probe->ToObject(&probe)) return maybe_probe;
1143 } 1176 }
1144 if (!probe->IsUndefined()) return probe; 1177 if (!probe->IsUndefined()) return probe;
1145 StubCompiler compiler; 1178 StubCompiler compiler;
1146 return FillCache(compiler.CompileCallMiss(flags)); 1179 return FillCache(isolate_, compiler.CompileCallMiss(flags));
1147 } 1180 }
1148 1181
1149 1182
1150 #ifdef ENABLE_DEBUGGER_SUPPORT 1183 #ifdef ENABLE_DEBUGGER_SUPPORT
1151 MaybeObject* StubCache::ComputeCallDebugBreak(int argc, Code::Kind kind) { 1184 MaybeObject* StubCache::ComputeCallDebugBreak(int argc, Code::Kind kind) {
1152 Code::Flags flags = Code::ComputeFlags(kind, 1185 Code::Flags flags = Code::ComputeFlags(kind,
1153 NOT_IN_LOOP, 1186 NOT_IN_LOOP,
1154 DEBUG_BREAK, 1187 DEBUG_BREAK,
1155 Code::kNoExtraICState, 1188 Code::kNoExtraICState,
1156 NORMAL, 1189 NORMAL,
1157 argc); 1190 argc);
1158 Object* probe; 1191 Object* probe;
1159 { MaybeObject* maybe_probe = ProbeCache(flags); 1192 { MaybeObject* maybe_probe = ProbeCache(isolate_, flags);
1160 if (!maybe_probe->ToObject(&probe)) return maybe_probe; 1193 if (!maybe_probe->ToObject(&probe)) return maybe_probe;
1161 } 1194 }
1162 if (!probe->IsUndefined()) return probe; 1195 if (!probe->IsUndefined()) return probe;
1163 StubCompiler compiler; 1196 StubCompiler compiler;
1164 return FillCache(compiler.CompileCallDebugBreak(flags)); 1197 return FillCache(isolate_, compiler.CompileCallDebugBreak(flags));
1165 } 1198 }
1166 1199
1167 1200
1168 MaybeObject* StubCache::ComputeCallDebugPrepareStepIn(int argc, 1201 MaybeObject* StubCache::ComputeCallDebugPrepareStepIn(int argc,
1169 Code::Kind kind) { 1202 Code::Kind kind) {
1170 Code::Flags flags = Code::ComputeFlags(kind, 1203 Code::Flags flags = Code::ComputeFlags(kind,
1171 NOT_IN_LOOP, 1204 NOT_IN_LOOP,
1172 DEBUG_PREPARE_STEP_IN, 1205 DEBUG_PREPARE_STEP_IN,
1173 Code::kNoExtraICState, 1206 Code::kNoExtraICState,
1174 NORMAL, 1207 NORMAL,
1175 argc); 1208 argc);
1176 Object* probe; 1209 Object* probe;
1177 { MaybeObject* maybe_probe = ProbeCache(flags); 1210 { MaybeObject* maybe_probe = ProbeCache(isolate_, flags);
1178 if (!maybe_probe->ToObject(&probe)) return maybe_probe; 1211 if (!maybe_probe->ToObject(&probe)) return maybe_probe;
1179 } 1212 }
1180 if (!probe->IsUndefined()) return probe; 1213 if (!probe->IsUndefined()) return probe;
1181 StubCompiler compiler; 1214 StubCompiler compiler;
1182 return FillCache(compiler.CompileCallDebugPrepareStepIn(flags)); 1215 return FillCache(isolate_, compiler.CompileCallDebugPrepareStepIn(flags));
1183 } 1216 }
1184 #endif 1217 #endif
1185 1218
1186 1219
1187 void StubCache::Clear() { 1220 void StubCache::Clear() {
1188 for (int i = 0; i < kPrimaryTableSize; i++) { 1221 for (int i = 0; i < kPrimaryTableSize; i++) {
1189 primary_[i].key = Heap::empty_string(); 1222 primary_[i].key = isolate_->heap()->empty_string();
1190 primary_[i].value = Builtins::builtin(Builtins::Illegal); 1223 primary_[i].value = isolate_->builtins()->builtin(
1224 Builtins::Illegal);
1191 } 1225 }
1192 for (int j = 0; j < kSecondaryTableSize; j++) { 1226 for (int j = 0; j < kSecondaryTableSize; j++) {
1193 secondary_[j].key = Heap::empty_string(); 1227 secondary_[j].key = isolate_->heap()->empty_string();
1194 secondary_[j].value = Builtins::builtin(Builtins::Illegal); 1228 secondary_[j].value = isolate_->builtins()->builtin(
1229 Builtins::Illegal);
1195 } 1230 }
1196 } 1231 }
1197 1232
1198 1233
1199 void StubCache::CollectMatchingMaps(ZoneMapList* types, 1234 void StubCache::CollectMatchingMaps(ZoneMapList* types,
1200 String* name, 1235 String* name,
1201 Code::Flags flags) { 1236 Code::Flags flags) {
1202 for (int i = 0; i < kPrimaryTableSize; i++) { 1237 for (int i = 0; i < kPrimaryTableSize; i++) {
1203 if (primary_[i].key == name) { 1238 if (primary_[i].key == name) {
1204 Map* map = primary_[i].value->FindFirstMap(); 1239 Map* map = primary_[i].value->FindFirstMap();
(...skipping 30 matching lines...) Expand all
1235 } 1270 }
1236 } 1271 }
1237 } 1272 }
1238 } 1273 }
1239 1274
1240 1275
1241 // ------------------------------------------------------------------------ 1276 // ------------------------------------------------------------------------
1242 // StubCompiler implementation. 1277 // StubCompiler implementation.
1243 1278
1244 1279
1245 MaybeObject* LoadCallbackProperty(Arguments args) { 1280 MaybeObject* LoadCallbackProperty(RUNTIME_CALLING_CONVENTION) {
1281 RUNTIME_GET_ISOLATE;
1246 ASSERT(args[0]->IsJSObject()); 1282 ASSERT(args[0]->IsJSObject());
1247 ASSERT(args[1]->IsJSObject()); 1283 ASSERT(args[1]->IsJSObject());
1248 AccessorInfo* callback = AccessorInfo::cast(args[3]); 1284 AccessorInfo* callback = AccessorInfo::cast(args[3]);
1249 Address getter_address = v8::ToCData<Address>(callback->getter()); 1285 Address getter_address = v8::ToCData<Address>(callback->getter());
1250 v8::AccessorGetter fun = FUNCTION_CAST<v8::AccessorGetter>(getter_address); 1286 v8::AccessorGetter fun = FUNCTION_CAST<v8::AccessorGetter>(getter_address);
1251 ASSERT(fun != NULL); 1287 ASSERT(fun != NULL);
1252 v8::AccessorInfo info(&args[0]); 1288 v8::AccessorInfo info(&args[0]);
1253 HandleScope scope; 1289 HandleScope scope(isolate);
1254 v8::Handle<v8::Value> result; 1290 v8::Handle<v8::Value> result;
1255 { 1291 {
1256 // Leaving JavaScript. 1292 // Leaving JavaScript.
1257 VMState state(EXTERNAL); 1293 VMState state(isolate, EXTERNAL);
1258 ExternalCallbackScope call_scope(getter_address); 1294 ExternalCallbackScope call_scope(isolate, getter_address);
1259 result = fun(v8::Utils::ToLocal(args.at<String>(4)), info); 1295 result = fun(v8::Utils::ToLocal(args.at<String>(4)), info);
1260 } 1296 }
1261 RETURN_IF_SCHEDULED_EXCEPTION(); 1297 RETURN_IF_SCHEDULED_EXCEPTION(isolate);
1262 if (result.IsEmpty()) return Heap::undefined_value(); 1298 if (result.IsEmpty()) return HEAP->undefined_value();
1263 return *v8::Utils::OpenHandle(*result); 1299 return *v8::Utils::OpenHandle(*result);
1264 } 1300 }
1265 1301
1266 1302
1267 MaybeObject* StoreCallbackProperty(Arguments args) { 1303 MaybeObject* StoreCallbackProperty(RUNTIME_CALLING_CONVENTION) {
1304 RUNTIME_GET_ISOLATE;
1268 JSObject* recv = JSObject::cast(args[0]); 1305 JSObject* recv = JSObject::cast(args[0]);
1269 AccessorInfo* callback = AccessorInfo::cast(args[1]); 1306 AccessorInfo* callback = AccessorInfo::cast(args[1]);
1270 Address setter_address = v8::ToCData<Address>(callback->setter()); 1307 Address setter_address = v8::ToCData<Address>(callback->setter());
1271 v8::AccessorSetter fun = FUNCTION_CAST<v8::AccessorSetter>(setter_address); 1308 v8::AccessorSetter fun = FUNCTION_CAST<v8::AccessorSetter>(setter_address);
1272 ASSERT(fun != NULL); 1309 ASSERT(fun != NULL);
1273 Handle<String> name = args.at<String>(2); 1310 Handle<String> name = args.at<String>(2);
1274 Handle<Object> value = args.at<Object>(3); 1311 Handle<Object> value = args.at<Object>(3);
1275 HandleScope scope; 1312 HandleScope scope(isolate);
1276 LOG(ApiNamedPropertyAccess("store", recv, *name)); 1313 LOG(isolate, ApiNamedPropertyAccess("store", recv, *name));
1277 CustomArguments custom_args(callback->data(), recv, recv); 1314 CustomArguments custom_args(isolate, callback->data(), recv, recv);
1278 v8::AccessorInfo info(custom_args.end()); 1315 v8::AccessorInfo info(custom_args.end());
1279 { 1316 {
1280 // Leaving JavaScript. 1317 // Leaving JavaScript.
1281 VMState state(EXTERNAL); 1318 VMState state(isolate, EXTERNAL);
1282 ExternalCallbackScope call_scope(setter_address); 1319 ExternalCallbackScope call_scope(isolate, setter_address);
1283 fun(v8::Utils::ToLocal(name), v8::Utils::ToLocal(value), info); 1320 fun(v8::Utils::ToLocal(name), v8::Utils::ToLocal(value), info);
1284 } 1321 }
1285 RETURN_IF_SCHEDULED_EXCEPTION(); 1322 RETURN_IF_SCHEDULED_EXCEPTION(isolate);
1286 return *value; 1323 return *value;
1287 } 1324 }
1288 1325
1289 1326
1290 static const int kAccessorInfoOffsetInInterceptorArgs = 2; 1327 static const int kAccessorInfoOffsetInInterceptorArgs = 2;
1291 1328
1292 1329
1293 /** 1330 /**
1294 * Attempts to load a property with an interceptor (which must be present), 1331 * Attempts to load a property with an interceptor (which must be present),
1295 * but doesn't search the prototype chain. 1332 * but doesn't search the prototype chain.
1296 * 1333 *
1297 * Returns |Heap::no_interceptor_result_sentinel()| if interceptor doesn't 1334 * Returns |Heap::no_interceptor_result_sentinel()| if interceptor doesn't
1298 * provide any value for the given name. 1335 * provide any value for the given name.
1299 */ 1336 */
1300 MaybeObject* LoadPropertyWithInterceptorOnly(Arguments args) { 1337 MaybeObject* LoadPropertyWithInterceptorOnly(RUNTIME_CALLING_CONVENTION) {
1338 RUNTIME_GET_ISOLATE;
1301 Handle<String> name_handle = args.at<String>(0); 1339 Handle<String> name_handle = args.at<String>(0);
1302 Handle<InterceptorInfo> interceptor_info = args.at<InterceptorInfo>(1); 1340 Handle<InterceptorInfo> interceptor_info = args.at<InterceptorInfo>(1);
1303 ASSERT(kAccessorInfoOffsetInInterceptorArgs == 2); 1341 ASSERT(kAccessorInfoOffsetInInterceptorArgs == 2);
1304 ASSERT(args[2]->IsJSObject()); // Receiver. 1342 ASSERT(args[2]->IsJSObject()); // Receiver.
1305 ASSERT(args[3]->IsJSObject()); // Holder. 1343 ASSERT(args[3]->IsJSObject()); // Holder.
1306 ASSERT(args.length() == 5); // Last arg is data object. 1344 ASSERT(args.length() == 5); // Last arg is data object.
1307 1345
1308 Address getter_address = v8::ToCData<Address>(interceptor_info->getter()); 1346 Address getter_address = v8::ToCData<Address>(interceptor_info->getter());
1309 v8::NamedPropertyGetter getter = 1347 v8::NamedPropertyGetter getter =
1310 FUNCTION_CAST<v8::NamedPropertyGetter>(getter_address); 1348 FUNCTION_CAST<v8::NamedPropertyGetter>(getter_address);
1311 ASSERT(getter != NULL); 1349 ASSERT(getter != NULL);
1312 1350
1313 { 1351 {
1314 // Use the interceptor getter. 1352 // Use the interceptor getter.
1315 v8::AccessorInfo info(args.arguments() - 1353 v8::AccessorInfo info(args.arguments() -
1316 kAccessorInfoOffsetInInterceptorArgs); 1354 kAccessorInfoOffsetInInterceptorArgs);
1317 HandleScope scope; 1355 HandleScope scope(isolate);
1318 v8::Handle<v8::Value> r; 1356 v8::Handle<v8::Value> r;
1319 { 1357 {
1320 // Leaving JavaScript. 1358 // Leaving JavaScript.
1321 VMState state(EXTERNAL); 1359 VMState state(isolate, EXTERNAL);
1322 r = getter(v8::Utils::ToLocal(name_handle), info); 1360 r = getter(v8::Utils::ToLocal(name_handle), info);
1323 } 1361 }
1324 RETURN_IF_SCHEDULED_EXCEPTION(); 1362 RETURN_IF_SCHEDULED_EXCEPTION(isolate);
1325 if (!r.IsEmpty()) { 1363 if (!r.IsEmpty()) {
1326 return *v8::Utils::OpenHandle(*r); 1364 return *v8::Utils::OpenHandle(*r);
1327 } 1365 }
1328 } 1366 }
1329 1367
1330 return Heap::no_interceptor_result_sentinel(); 1368 return isolate->heap()->no_interceptor_result_sentinel();
1331 } 1369 }
1332 1370
1333 1371
1334 static MaybeObject* ThrowReferenceError(String* name) { 1372 static MaybeObject* ThrowReferenceError(String* name) {
1335 // If the load is non-contextual, just return the undefined result. 1373 // If the load is non-contextual, just return the undefined result.
1336 // Note that both keyed and non-keyed loads may end up here, so we 1374 // Note that both keyed and non-keyed loads may end up here, so we
1337 // can't use either LoadIC or KeyedLoadIC constructors. 1375 // can't use either LoadIC or KeyedLoadIC constructors.
1338 IC ic(IC::NO_EXTRA_FRAME); 1376 IC ic(IC::NO_EXTRA_FRAME, Isolate::Current());
1339 ASSERT(ic.target()->is_load_stub() || ic.target()->is_keyed_load_stub()); 1377 ASSERT(ic.target()->is_load_stub() || ic.target()->is_keyed_load_stub());
1340 if (!ic.SlowIsContextual()) return Heap::undefined_value(); 1378 if (!ic.SlowIsContextual()) return HEAP->undefined_value();
1341 1379
1342 // Throw a reference error. 1380 // Throw a reference error.
1343 HandleScope scope; 1381 HandleScope scope;
1344 Handle<String> name_handle(name); 1382 Handle<String> name_handle(name);
1345 Handle<Object> error = 1383 Handle<Object> error =
1346 Factory::NewReferenceError("not_defined", 1384 FACTORY->NewReferenceError("not_defined",
1347 HandleVector(&name_handle, 1)); 1385 HandleVector(&name_handle, 1));
1348 return Top::Throw(*error); 1386 return Isolate::Current()->Throw(*error);
1349 } 1387 }
1350 1388
1351 1389
1352 static MaybeObject* LoadWithInterceptor(Arguments* args, 1390 static MaybeObject* LoadWithInterceptor(Arguments* args,
1353 PropertyAttributes* attrs) { 1391 PropertyAttributes* attrs) {
1354 Handle<String> name_handle = args->at<String>(0); 1392 Handle<String> name_handle = args->at<String>(0);
1355 Handle<InterceptorInfo> interceptor_info = args->at<InterceptorInfo>(1); 1393 Handle<InterceptorInfo> interceptor_info = args->at<InterceptorInfo>(1);
1356 ASSERT(kAccessorInfoOffsetInInterceptorArgs == 2); 1394 ASSERT(kAccessorInfoOffsetInInterceptorArgs == 2);
1357 Handle<JSObject> receiver_handle = args->at<JSObject>(2); 1395 Handle<JSObject> receiver_handle = args->at<JSObject>(2);
1358 Handle<JSObject> holder_handle = args->at<JSObject>(3); 1396 Handle<JSObject> holder_handle = args->at<JSObject>(3);
1359 ASSERT(args->length() == 5); // Last arg is data object. 1397 ASSERT(args->length() == 5); // Last arg is data object.
1360 1398
1399 Isolate* isolate = receiver_handle->GetIsolate();
1400
1361 Address getter_address = v8::ToCData<Address>(interceptor_info->getter()); 1401 Address getter_address = v8::ToCData<Address>(interceptor_info->getter());
1362 v8::NamedPropertyGetter getter = 1402 v8::NamedPropertyGetter getter =
1363 FUNCTION_CAST<v8::NamedPropertyGetter>(getter_address); 1403 FUNCTION_CAST<v8::NamedPropertyGetter>(getter_address);
1364 ASSERT(getter != NULL); 1404 ASSERT(getter != NULL);
1365 1405
1366 { 1406 {
1367 // Use the interceptor getter. 1407 // Use the interceptor getter.
1368 v8::AccessorInfo info(args->arguments() - 1408 v8::AccessorInfo info(args->arguments() -
1369 kAccessorInfoOffsetInInterceptorArgs); 1409 kAccessorInfoOffsetInInterceptorArgs);
1370 HandleScope scope; 1410 HandleScope scope(isolate);
1371 v8::Handle<v8::Value> r; 1411 v8::Handle<v8::Value> r;
1372 { 1412 {
1373 // Leaving JavaScript. 1413 // Leaving JavaScript.
1374 VMState state(EXTERNAL); 1414 VMState state(isolate, EXTERNAL);
1375 r = getter(v8::Utils::ToLocal(name_handle), info); 1415 r = getter(v8::Utils::ToLocal(name_handle), info);
1376 } 1416 }
1377 RETURN_IF_SCHEDULED_EXCEPTION(); 1417 RETURN_IF_SCHEDULED_EXCEPTION(isolate);
1378 if (!r.IsEmpty()) { 1418 if (!r.IsEmpty()) {
1379 *attrs = NONE; 1419 *attrs = NONE;
1380 return *v8::Utils::OpenHandle(*r); 1420 return *v8::Utils::OpenHandle(*r);
1381 } 1421 }
1382 } 1422 }
1383 1423
1384 MaybeObject* result = holder_handle->GetPropertyPostInterceptor( 1424 MaybeObject* result = holder_handle->GetPropertyPostInterceptor(
1385 *receiver_handle, 1425 *receiver_handle,
1386 *name_handle, 1426 *name_handle,
1387 attrs); 1427 attrs);
1388 RETURN_IF_SCHEDULED_EXCEPTION(); 1428 RETURN_IF_SCHEDULED_EXCEPTION(isolate);
1389 return result; 1429 return result;
1390 } 1430 }
1391 1431
1392 1432
1393 /** 1433 /**
1394 * Loads a property with an interceptor performing post interceptor 1434 * Loads a property with an interceptor performing post interceptor
1395 * lookup if interceptor failed. 1435 * lookup if interceptor failed.
1396 */ 1436 */
1397 MaybeObject* LoadPropertyWithInterceptorForLoad(Arguments args) { 1437 MaybeObject* LoadPropertyWithInterceptorForLoad(RUNTIME_CALLING_CONVENTION) {
1438 RUNTIME_GET_ISOLATE;
1398 PropertyAttributes attr = NONE; 1439 PropertyAttributes attr = NONE;
1399 Object* result; 1440 Object* result;
1400 { MaybeObject* maybe_result = LoadWithInterceptor(&args, &attr); 1441 { MaybeObject* maybe_result = LoadWithInterceptor(&args, &attr);
1401 if (!maybe_result->ToObject(&result)) return maybe_result; 1442 if (!maybe_result->ToObject(&result)) return maybe_result;
1402 } 1443 }
1403 1444
1404 // If the property is present, return it. 1445 // If the property is present, return it.
1405 if (attr != ABSENT) return result; 1446 if (attr != ABSENT) return result;
1406 return ThrowReferenceError(String::cast(args[0])); 1447 return ThrowReferenceError(String::cast(args[0]));
1407 } 1448 }
1408 1449
1409 1450
1410 MaybeObject* LoadPropertyWithInterceptorForCall(Arguments args) { 1451 MaybeObject* LoadPropertyWithInterceptorForCall(RUNTIME_CALLING_CONVENTION) {
1452 RUNTIME_GET_ISOLATE;
1411 PropertyAttributes attr; 1453 PropertyAttributes attr;
1412 MaybeObject* result = LoadWithInterceptor(&args, &attr); 1454 MaybeObject* result = LoadWithInterceptor(&args, &attr);
1413 RETURN_IF_SCHEDULED_EXCEPTION(); 1455 RETURN_IF_SCHEDULED_EXCEPTION(isolate);
1414 // This is call IC. In this case, we simply return the undefined result which 1456 // This is call IC. In this case, we simply return the undefined result which
1415 // will lead to an exception when trying to invoke the result as a 1457 // will lead to an exception when trying to invoke the result as a
1416 // function. 1458 // function.
1417 return result; 1459 return result;
1418 } 1460 }
1419 1461
1420 1462
1421 MaybeObject* StoreInterceptorProperty(Arguments args) { 1463 MaybeObject* StoreInterceptorProperty(RUNTIME_CALLING_CONVENTION) {
1464 RUNTIME_GET_ISOLATE;
1422 ASSERT(args.length() == 4); 1465 ASSERT(args.length() == 4);
1423 JSObject* recv = JSObject::cast(args[0]); 1466 JSObject* recv = JSObject::cast(args[0]);
1424 String* name = String::cast(args[1]); 1467 String* name = String::cast(args[1]);
1425 Object* value = args[2]; 1468 Object* value = args[2];
1426 StrictModeFlag strict_mode = 1469 StrictModeFlag strict_mode =
1427 static_cast<StrictModeFlag>(Smi::cast(args[3])->value()); 1470 static_cast<StrictModeFlag>(Smi::cast(args[3])->value());
1428 ASSERT(strict_mode == kStrictMode || strict_mode == kNonStrictMode); 1471 ASSERT(strict_mode == kStrictMode || strict_mode == kNonStrictMode);
1429 ASSERT(recv->HasNamedInterceptor()); 1472 ASSERT(recv->HasNamedInterceptor());
1430 PropertyAttributes attr = NONE; 1473 PropertyAttributes attr = NONE;
1431 MaybeObject* result = recv->SetPropertyWithInterceptor( 1474 MaybeObject* result = recv->SetPropertyWithInterceptor(
1432 name, value, attr, strict_mode); 1475 name, value, attr, strict_mode);
1433 return result; 1476 return result;
1434 } 1477 }
1435 1478
1436 1479
1437 MaybeObject* KeyedLoadPropertyWithInterceptor(Arguments args) { 1480 MaybeObject* KeyedLoadPropertyWithInterceptor(RUNTIME_CALLING_CONVENTION) {
1481 RUNTIME_GET_ISOLATE;
1438 JSObject* receiver = JSObject::cast(args[0]); 1482 JSObject* receiver = JSObject::cast(args[0]);
1439 ASSERT(Smi::cast(args[1])->value() >= 0); 1483 ASSERT(Smi::cast(args[1])->value() >= 0);
1440 uint32_t index = Smi::cast(args[1])->value(); 1484 uint32_t index = Smi::cast(args[1])->value();
1441 return receiver->GetElementWithInterceptor(receiver, index); 1485 return receiver->GetElementWithInterceptor(receiver, index);
1442 } 1486 }
1443 1487
1444 1488
1445 MaybeObject* StubCompiler::CompileCallInitialize(Code::Flags flags) { 1489 MaybeObject* StubCompiler::CompileCallInitialize(Code::Flags flags) {
1446 HandleScope scope; 1490 HandleScope scope(isolate());
1447 int argc = Code::ExtractArgumentsCountFromFlags(flags); 1491 int argc = Code::ExtractArgumentsCountFromFlags(flags);
1448 Code::Kind kind = Code::ExtractKindFromFlags(flags); 1492 Code::Kind kind = Code::ExtractKindFromFlags(flags);
1449 if (kind == Code::CALL_IC) { 1493 if (kind == Code::CALL_IC) {
1450 CallIC::GenerateInitialize(masm(), argc); 1494 CallIC::GenerateInitialize(masm(), argc);
1451 } else { 1495 } else {
1452 KeyedCallIC::GenerateInitialize(masm(), argc); 1496 KeyedCallIC::GenerateInitialize(masm(), argc);
1453 } 1497 }
1454 Object* result; 1498 Object* result;
1455 { MaybeObject* maybe_result = 1499 { MaybeObject* maybe_result =
1456 GetCodeWithFlags(flags, "CompileCallInitialize"); 1500 GetCodeWithFlags(flags, "CompileCallInitialize");
1457 if (!maybe_result->ToObject(&result)) return maybe_result; 1501 if (!maybe_result->ToObject(&result)) return maybe_result;
1458 } 1502 }
1459 Counters::call_initialize_stubs.Increment(); 1503 COUNTERS->call_initialize_stubs()->Increment();
1460 Code* code = Code::cast(result); 1504 Code* code = Code::cast(result);
1461 USE(code); 1505 USE(code);
1462 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_INITIALIZE_TAG), 1506 PROFILE(isolate(),
1507 CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_INITIALIZE_TAG),
1463 code, code->arguments_count())); 1508 code, code->arguments_count()));
1464 GDBJIT(AddCode(GDBJITInterface::CALL_INITIALIZE, Code::cast(code))); 1509 GDBJIT(AddCode(GDBJITInterface::CALL_INITIALIZE, Code::cast(code)));
1465 return result; 1510 return result;
1466 } 1511 }
1467 1512
1468 1513
1469 MaybeObject* StubCompiler::CompileCallPreMonomorphic(Code::Flags flags) { 1514 MaybeObject* StubCompiler::CompileCallPreMonomorphic(Code::Flags flags) {
1470 HandleScope scope; 1515 HandleScope scope(isolate());
1471 int argc = Code::ExtractArgumentsCountFromFlags(flags); 1516 int argc = Code::ExtractArgumentsCountFromFlags(flags);
1472 // The code of the PreMonomorphic stub is the same as the code 1517 // The code of the PreMonomorphic stub is the same as the code
1473 // of the Initialized stub. They just differ on the code object flags. 1518 // of the Initialized stub. They just differ on the code object flags.
1474 Code::Kind kind = Code::ExtractKindFromFlags(flags); 1519 Code::Kind kind = Code::ExtractKindFromFlags(flags);
1475 if (kind == Code::CALL_IC) { 1520 if (kind == Code::CALL_IC) {
1476 CallIC::GenerateInitialize(masm(), argc); 1521 CallIC::GenerateInitialize(masm(), argc);
1477 } else { 1522 } else {
1478 KeyedCallIC::GenerateInitialize(masm(), argc); 1523 KeyedCallIC::GenerateInitialize(masm(), argc);
1479 } 1524 }
1480 Object* result; 1525 Object* result;
1481 { MaybeObject* maybe_result = 1526 { MaybeObject* maybe_result =
1482 GetCodeWithFlags(flags, "CompileCallPreMonomorphic"); 1527 GetCodeWithFlags(flags, "CompileCallPreMonomorphic");
1483 if (!maybe_result->ToObject(&result)) return maybe_result; 1528 if (!maybe_result->ToObject(&result)) return maybe_result;
1484 } 1529 }
1485 Counters::call_premonomorphic_stubs.Increment(); 1530 COUNTERS->call_premonomorphic_stubs()->Increment();
1486 Code* code = Code::cast(result); 1531 Code* code = Code::cast(result);
1487 USE(code); 1532 USE(code);
1488 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_PRE_MONOMORPHIC_TAG), 1533 PROFILE(isolate(),
1534 CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_PRE_MONOMORPHIC_TAG),
1489 code, code->arguments_count())); 1535 code, code->arguments_count()));
1490 GDBJIT(AddCode(GDBJITInterface::CALL_PRE_MONOMORPHIC, Code::cast(code))); 1536 GDBJIT(AddCode(GDBJITInterface::CALL_PRE_MONOMORPHIC, Code::cast(code)));
1491 return result; 1537 return result;
1492 } 1538 }
1493 1539
1494 1540
1495 MaybeObject* StubCompiler::CompileCallNormal(Code::Flags flags) { 1541 MaybeObject* StubCompiler::CompileCallNormal(Code::Flags flags) {
1496 HandleScope scope; 1542 HandleScope scope(isolate());
1497 int argc = Code::ExtractArgumentsCountFromFlags(flags); 1543 int argc = Code::ExtractArgumentsCountFromFlags(flags);
1498 Code::Kind kind = Code::ExtractKindFromFlags(flags); 1544 Code::Kind kind = Code::ExtractKindFromFlags(flags);
1499 if (kind == Code::CALL_IC) { 1545 if (kind == Code::CALL_IC) {
1500 CallIC::GenerateNormal(masm(), argc); 1546 CallIC::GenerateNormal(masm(), argc);
1501 } else { 1547 } else {
1502 KeyedCallIC::GenerateNormal(masm(), argc); 1548 KeyedCallIC::GenerateNormal(masm(), argc);
1503 } 1549 }
1504 Object* result; 1550 Object* result;
1505 { MaybeObject* maybe_result = GetCodeWithFlags(flags, "CompileCallNormal"); 1551 { MaybeObject* maybe_result = GetCodeWithFlags(flags, "CompileCallNormal");
1506 if (!maybe_result->ToObject(&result)) return maybe_result; 1552 if (!maybe_result->ToObject(&result)) return maybe_result;
1507 } 1553 }
1508 Counters::call_normal_stubs.Increment(); 1554 COUNTERS->call_normal_stubs()->Increment();
1509 Code* code = Code::cast(result); 1555 Code* code = Code::cast(result);
1510 USE(code); 1556 USE(code);
1511 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_NORMAL_TAG), 1557 PROFILE(isolate(),
1558 CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_NORMAL_TAG),
1512 code, code->arguments_count())); 1559 code, code->arguments_count()));
1513 GDBJIT(AddCode(GDBJITInterface::CALL_NORMAL, Code::cast(code))); 1560 GDBJIT(AddCode(GDBJITInterface::CALL_NORMAL, Code::cast(code)));
1514 return result; 1561 return result;
1515 } 1562 }
1516 1563
1517 1564
1518 MaybeObject* StubCompiler::CompileCallMegamorphic(Code::Flags flags) { 1565 MaybeObject* StubCompiler::CompileCallMegamorphic(Code::Flags flags) {
1519 HandleScope scope; 1566 HandleScope scope(isolate());
1520 int argc = Code::ExtractArgumentsCountFromFlags(flags); 1567 int argc = Code::ExtractArgumentsCountFromFlags(flags);
1521 Code::Kind kind = Code::ExtractKindFromFlags(flags); 1568 Code::Kind kind = Code::ExtractKindFromFlags(flags);
1522 if (kind == Code::CALL_IC) { 1569 if (kind == Code::CALL_IC) {
1523 CallIC::GenerateMegamorphic(masm(), argc); 1570 CallIC::GenerateMegamorphic(masm(), argc);
1524 } else { 1571 } else {
1525 KeyedCallIC::GenerateMegamorphic(masm(), argc); 1572 KeyedCallIC::GenerateMegamorphic(masm(), argc);
1526 } 1573 }
1527
1528 Object* result; 1574 Object* result;
1529 { MaybeObject* maybe_result = 1575 { MaybeObject* maybe_result =
1530 GetCodeWithFlags(flags, "CompileCallMegamorphic"); 1576 GetCodeWithFlags(flags, "CompileCallMegamorphic");
1531 if (!maybe_result->ToObject(&result)) return maybe_result; 1577 if (!maybe_result->ToObject(&result)) return maybe_result;
1532 } 1578 }
1533 Counters::call_megamorphic_stubs.Increment(); 1579 COUNTERS->call_megamorphic_stubs()->Increment();
1534 Code* code = Code::cast(result); 1580 Code* code = Code::cast(result);
1535 USE(code); 1581 USE(code);
1536 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_MEGAMORPHIC_TAG), 1582 PROFILE(isolate(),
1583 CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_MEGAMORPHIC_TAG),
1537 code, code->arguments_count())); 1584 code, code->arguments_count()));
1538 GDBJIT(AddCode(GDBJITInterface::CALL_MEGAMORPHIC, Code::cast(code))); 1585 GDBJIT(AddCode(GDBJITInterface::CALL_MEGAMORPHIC, Code::cast(code)));
1539 return result; 1586 return result;
1540 } 1587 }
1541 1588
1542 1589
1543 MaybeObject* StubCompiler::CompileCallMiss(Code::Flags flags) { 1590 MaybeObject* StubCompiler::CompileCallMiss(Code::Flags flags) {
1544 HandleScope scope; 1591 HandleScope scope(isolate());
1545 int argc = Code::ExtractArgumentsCountFromFlags(flags); 1592 int argc = Code::ExtractArgumentsCountFromFlags(flags);
1546 Code::Kind kind = Code::ExtractKindFromFlags(flags); 1593 Code::Kind kind = Code::ExtractKindFromFlags(flags);
1547 if (kind == Code::CALL_IC) { 1594 if (kind == Code::CALL_IC) {
1548 CallIC::GenerateMiss(masm(), argc); 1595 CallIC::GenerateMiss(masm(), argc);
1549 } else { 1596 } else {
1550 KeyedCallIC::GenerateMiss(masm(), argc); 1597 KeyedCallIC::GenerateMiss(masm(), argc);
1551 } 1598 }
1552 Object* result; 1599 Object* result;
1553 { MaybeObject* maybe_result = GetCodeWithFlags(flags, "CompileCallMiss"); 1600 { MaybeObject* maybe_result = GetCodeWithFlags(flags, "CompileCallMiss");
1554 if (!maybe_result->ToObject(&result)) return maybe_result; 1601 if (!maybe_result->ToObject(&result)) return maybe_result;
1555 } 1602 }
1556 Counters::call_megamorphic_stubs.Increment(); 1603 COUNTERS->call_megamorphic_stubs()->Increment();
1557 Code* code = Code::cast(result); 1604 Code* code = Code::cast(result);
1558 USE(code); 1605 USE(code);
1559 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_MISS_TAG), 1606 PROFILE(isolate(),
1607 CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_MISS_TAG),
1560 code, code->arguments_count())); 1608 code, code->arguments_count()));
1561 GDBJIT(AddCode(GDBJITInterface::CALL_MISS, Code::cast(code))); 1609 GDBJIT(AddCode(GDBJITInterface::CALL_MISS, Code::cast(code)));
1562 return result; 1610 return result;
1563 } 1611 }
1564 1612
1565 1613
1566 #ifdef ENABLE_DEBUGGER_SUPPORT 1614 #ifdef ENABLE_DEBUGGER_SUPPORT
1567 MaybeObject* StubCompiler::CompileCallDebugBreak(Code::Flags flags) { 1615 MaybeObject* StubCompiler::CompileCallDebugBreak(Code::Flags flags) {
1568 HandleScope scope; 1616 HandleScope scope(isolate());
1569 Debug::GenerateCallICDebugBreak(masm()); 1617 Debug::GenerateCallICDebugBreak(masm());
1570 Object* result; 1618 Object* result;
1571 { MaybeObject* maybe_result = 1619 { MaybeObject* maybe_result =
1572 GetCodeWithFlags(flags, "CompileCallDebugBreak"); 1620 GetCodeWithFlags(flags, "CompileCallDebugBreak");
1573 if (!maybe_result->ToObject(&result)) return maybe_result; 1621 if (!maybe_result->ToObject(&result)) return maybe_result;
1574 } 1622 }
1575 Code* code = Code::cast(result); 1623 Code* code = Code::cast(result);
1576 USE(code); 1624 USE(code);
1577 Code::Kind kind = Code::ExtractKindFromFlags(flags); 1625 Code::Kind kind = Code::ExtractKindFromFlags(flags);
1578 USE(kind); 1626 USE(kind);
1579 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_DEBUG_BREAK_TAG), 1627 PROFILE(isolate(),
1628 CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_DEBUG_BREAK_TAG),
1580 code, code->arguments_count())); 1629 code, code->arguments_count()));
1581 return result; 1630 return result;
1582 } 1631 }
1583 1632
1584 1633
1585 MaybeObject* StubCompiler::CompileCallDebugPrepareStepIn(Code::Flags flags) { 1634 MaybeObject* StubCompiler::CompileCallDebugPrepareStepIn(Code::Flags flags) {
1586 HandleScope scope; 1635 HandleScope scope(isolate());
1587 // Use the same code for the the step in preparations as we do for 1636 // Use the same code for the the step in preparations as we do for
1588 // the miss case. 1637 // the miss case.
1589 int argc = Code::ExtractArgumentsCountFromFlags(flags); 1638 int argc = Code::ExtractArgumentsCountFromFlags(flags);
1590 Code::Kind kind = Code::ExtractKindFromFlags(flags); 1639 Code::Kind kind = Code::ExtractKindFromFlags(flags);
1591 if (kind == Code::CALL_IC) { 1640 if (kind == Code::CALL_IC) {
1592 CallIC::GenerateMiss(masm(), argc); 1641 CallIC::GenerateMiss(masm(), argc);
1593 } else { 1642 } else {
1594 KeyedCallIC::GenerateMiss(masm(), argc); 1643 KeyedCallIC::GenerateMiss(masm(), argc);
1595 } 1644 }
1596 Object* result; 1645 Object* result;
1597 { MaybeObject* maybe_result = 1646 { MaybeObject* maybe_result =
1598 GetCodeWithFlags(flags, "CompileCallDebugPrepareStepIn"); 1647 GetCodeWithFlags(flags, "CompileCallDebugPrepareStepIn");
1599 if (!maybe_result->ToObject(&result)) return maybe_result; 1648 if (!maybe_result->ToObject(&result)) return maybe_result;
1600 } 1649 }
1601 Code* code = Code::cast(result); 1650 Code* code = Code::cast(result);
1602 USE(code); 1651 USE(code);
1603 PROFILE(CodeCreateEvent( 1652 PROFILE(isolate(),
1604 CALL_LOGGER_TAG(kind, CALL_DEBUG_PREPARE_STEP_IN_TAG), 1653 CodeCreateEvent(
1605 code, 1654 CALL_LOGGER_TAG(kind, CALL_DEBUG_PREPARE_STEP_IN_TAG),
1606 code->arguments_count())); 1655 code,
1656 code->arguments_count()));
1607 return result; 1657 return result;
1608 } 1658 }
1609 #endif 1659 #endif
1610 1660
1611 #undef CALL_LOGGER_TAG 1661 #undef CALL_LOGGER_TAG
1612 1662
1613 MaybeObject* StubCompiler::GetCodeWithFlags(Code::Flags flags, 1663 MaybeObject* StubCompiler::GetCodeWithFlags(Code::Flags flags,
1614 const char* name) { 1664 const char* name) {
1615 // Check for allocation failures during stub compilation. 1665 // Check for allocation failures during stub compilation.
1616 if (failure_->IsFailure()) return failure_; 1666 if (failure_->IsFailure()) return failure_;
1617 1667
1618 // Create code object in the heap. 1668 // Create code object in the heap.
1619 CodeDesc desc; 1669 CodeDesc desc;
1620 masm_.GetCode(&desc); 1670 masm_.GetCode(&desc);
1621 MaybeObject* result = Heap::CreateCode(desc, flags, masm_.CodeObject()); 1671 MaybeObject* result = HEAP->CreateCode(desc, flags, masm_.CodeObject());
1622 #ifdef ENABLE_DISASSEMBLER 1672 #ifdef ENABLE_DISASSEMBLER
1623 if (FLAG_print_code_stubs && !result->IsFailure()) { 1673 if (FLAG_print_code_stubs && !result->IsFailure()) {
1624 Code::cast(result->ToObjectUnchecked())->Disassemble(name); 1674 Code::cast(result->ToObjectUnchecked())->Disassemble(name);
1625 } 1675 }
1626 #endif 1676 #endif
1627 return result; 1677 return result;
1628 } 1678 }
1629 1679
1630 1680
1631 MaybeObject* StubCompiler::GetCodeWithFlags(Code::Flags flags, String* name) { 1681 MaybeObject* StubCompiler::GetCodeWithFlags(Code::Flags flags, String* name) {
1632 if (FLAG_print_code_stubs && (name != NULL)) { 1682 if (FLAG_print_code_stubs && (name != NULL)) {
1633 return GetCodeWithFlags(flags, *name->ToCString()); 1683 return GetCodeWithFlags(flags, *name->ToCString());
1634 } 1684 }
1635 return GetCodeWithFlags(flags, reinterpret_cast<char*>(NULL)); 1685 return GetCodeWithFlags(flags, reinterpret_cast<char*>(NULL));
1636 } 1686 }
1637 1687
1638 1688
1639 void StubCompiler::LookupPostInterceptor(JSObject* holder, 1689 void StubCompiler::LookupPostInterceptor(JSObject* holder,
1640 String* name, 1690 String* name,
1641 LookupResult* lookup) { 1691 LookupResult* lookup) {
1642 holder->LocalLookupRealNamedProperty(name, lookup); 1692 holder->LocalLookupRealNamedProperty(name, lookup);
1643 if (!lookup->IsProperty()) { 1693 if (!lookup->IsProperty()) {
1644 lookup->NotFound(); 1694 lookup->NotFound();
1645 Object* proto = holder->GetPrototype(); 1695 Object* proto = holder->GetPrototype();
1646 if (proto != Heap::null_value()) { 1696 if (!proto->IsNull()) {
1647 proto->Lookup(name, lookup); 1697 proto->Lookup(name, lookup);
1648 } 1698 }
1649 } 1699 }
1650 } 1700 }
1651 1701
1652 1702
1653 1703
1654 MaybeObject* LoadStubCompiler::GetCode(PropertyType type, String* name) { 1704 MaybeObject* LoadStubCompiler::GetCode(PropertyType type, String* name) {
1655 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, type); 1705 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, type);
1656 MaybeObject* result = GetCodeWithFlags(flags, name); 1706 MaybeObject* result = GetCodeWithFlags(flags, name);
1657 if (!result->IsFailure()) { 1707 if (!result->IsFailure()) {
1658 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, 1708 PROFILE(isolate(),
1709 CodeCreateEvent(Logger::LOAD_IC_TAG,
1659 Code::cast(result->ToObjectUnchecked()), 1710 Code::cast(result->ToObjectUnchecked()),
1660 name)); 1711 name));
1661 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, 1712 GDBJIT(AddCode(GDBJITInterface::LOAD_IC,
1662 name, 1713 name,
1663 Code::cast(result->ToObjectUnchecked()))); 1714 Code::cast(result->ToObjectUnchecked())));
1664 } 1715 }
1665 return result; 1716 return result;
1666 } 1717 }
1667 1718
1668 1719
1669 MaybeObject* KeyedLoadStubCompiler::GetCode(PropertyType type, String* name) { 1720 MaybeObject* KeyedLoadStubCompiler::GetCode(PropertyType type, String* name) {
1670 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, type); 1721 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, type);
1671 MaybeObject* result = GetCodeWithFlags(flags, name); 1722 MaybeObject* result = GetCodeWithFlags(flags, name);
1672 if (!result->IsFailure()) { 1723 if (!result->IsFailure()) {
1673 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, 1724 PROFILE(isolate(),
1725 CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG,
1674 Code::cast(result->ToObjectUnchecked()), 1726 Code::cast(result->ToObjectUnchecked()),
1675 name)); 1727 name));
1676 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, 1728 GDBJIT(AddCode(GDBJITInterface::LOAD_IC,
1677 name, 1729 name,
1678 Code::cast(result->ToObjectUnchecked()))); 1730 Code::cast(result->ToObjectUnchecked())));
1679 } 1731 }
1680 return result; 1732 return result;
1681 } 1733 }
1682 1734
1683 1735
1684 MaybeObject* StoreStubCompiler::GetCode(PropertyType type, String* name) { 1736 MaybeObject* StoreStubCompiler::GetCode(PropertyType type, String* name) {
1685 Code::Flags flags = Code::ComputeMonomorphicFlags( 1737 Code::Flags flags = Code::ComputeMonomorphicFlags(
1686 Code::STORE_IC, type, strict_mode_); 1738 Code::STORE_IC, type, strict_mode_);
1687 MaybeObject* result = GetCodeWithFlags(flags, name); 1739 MaybeObject* result = GetCodeWithFlags(flags, name);
1688 if (!result->IsFailure()) { 1740 if (!result->IsFailure()) {
1689 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, 1741 PROFILE(isolate(),
1742 CodeCreateEvent(Logger::STORE_IC_TAG,
1690 Code::cast(result->ToObjectUnchecked()), 1743 Code::cast(result->ToObjectUnchecked()),
1691 name)); 1744 name));
1692 GDBJIT(AddCode(GDBJITInterface::STORE_IC, 1745 GDBJIT(AddCode(GDBJITInterface::STORE_IC,
1693 name, 1746 name,
1694 Code::cast(result->ToObjectUnchecked()))); 1747 Code::cast(result->ToObjectUnchecked())));
1695 } 1748 }
1696 return result; 1749 return result;
1697 } 1750 }
1698 1751
1699 1752
1700 MaybeObject* KeyedStoreStubCompiler::GetCode(PropertyType type, String* name) { 1753 MaybeObject* KeyedStoreStubCompiler::GetCode(PropertyType type, String* name) {
1701 Code::Flags flags = Code::ComputeMonomorphicFlags( 1754 Code::Flags flags = Code::ComputeMonomorphicFlags(
1702 Code::KEYED_STORE_IC, type, strict_mode_); 1755 Code::KEYED_STORE_IC, type, strict_mode_);
1703 MaybeObject* result = GetCodeWithFlags(flags, name); 1756 MaybeObject* result = GetCodeWithFlags(flags, name);
1704 if (!result->IsFailure()) { 1757 if (!result->IsFailure()) {
1705 PROFILE(CodeCreateEvent(Logger::KEYED_STORE_IC_TAG, 1758 PROFILE(isolate(),
1759 CodeCreateEvent(Logger::KEYED_STORE_IC_TAG,
1706 Code::cast(result->ToObjectUnchecked()), 1760 Code::cast(result->ToObjectUnchecked()),
1707 name)); 1761 name));
1708 GDBJIT(AddCode(GDBJITInterface::KEYED_STORE_IC, 1762 GDBJIT(AddCode(GDBJITInterface::KEYED_STORE_IC,
1709 name, 1763 name,
1710 Code::cast(result->ToObjectUnchecked()))); 1764 Code::cast(result->ToObjectUnchecked())));
1711 } 1765 }
1712 return result; 1766 return result;
1713 } 1767 }
1714 1768
1715 1769
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1796 1850
1797 1851
1798 MaybeObject* ConstructStubCompiler::GetCode() { 1852 MaybeObject* ConstructStubCompiler::GetCode() {
1799 Code::Flags flags = Code::ComputeFlags(Code::STUB); 1853 Code::Flags flags = Code::ComputeFlags(Code::STUB);
1800 Object* result; 1854 Object* result;
1801 { MaybeObject* maybe_result = GetCodeWithFlags(flags, "ConstructStub"); 1855 { MaybeObject* maybe_result = GetCodeWithFlags(flags, "ConstructStub");
1802 if (!maybe_result->ToObject(&result)) return maybe_result; 1856 if (!maybe_result->ToObject(&result)) return maybe_result;
1803 } 1857 }
1804 Code* code = Code::cast(result); 1858 Code* code = Code::cast(result);
1805 USE(code); 1859 USE(code);
1806 PROFILE(CodeCreateEvent(Logger::STUB_TAG, code, "ConstructStub")); 1860 PROFILE(isolate(), CodeCreateEvent(Logger::STUB_TAG, code, "ConstructStub"));
1807 GDBJIT(AddCode(GDBJITInterface::STUB, "ConstructStub", Code::cast(code))); 1861 GDBJIT(AddCode(GDBJITInterface::STUB, "ConstructStub", Code::cast(code)));
1808 return result; 1862 return result;
1809 } 1863 }
1810 1864
1811 1865
1812 CallOptimization::CallOptimization(LookupResult* lookup) { 1866 CallOptimization::CallOptimization(LookupResult* lookup) {
1813 if (!lookup->IsProperty() || !lookup->IsCacheable() || 1867 if (!lookup->IsProperty() || !lookup->IsCacheable() ||
1814 lookup->type() != CONSTANT_FUNCTION) { 1868 lookup->type() != CONSTANT_FUNCTION) {
1815 Initialize(NULL); 1869 Initialize(NULL);
1816 } else { 1870 } else {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1876 } 1930 }
1877 1931
1878 1932
1879 MaybeObject* ExternalArrayStubCompiler::GetCode(Code::Flags flags) { 1933 MaybeObject* ExternalArrayStubCompiler::GetCode(Code::Flags flags) {
1880 Object* result; 1934 Object* result;
1881 { MaybeObject* maybe_result = GetCodeWithFlags(flags, "ExternalArrayStub"); 1935 { MaybeObject* maybe_result = GetCodeWithFlags(flags, "ExternalArrayStub");
1882 if (!maybe_result->ToObject(&result)) return maybe_result; 1936 if (!maybe_result->ToObject(&result)) return maybe_result;
1883 } 1937 }
1884 Code* code = Code::cast(result); 1938 Code* code = Code::cast(result);
1885 USE(code); 1939 USE(code);
1886 PROFILE(CodeCreateEvent(Logger::STUB_TAG, code, "ExternalArrayStub")); 1940 PROFILE(isolate(),
1941 CodeCreateEvent(Logger::STUB_TAG, code, "ExternalArrayStub"));
1887 return result; 1942 return result;
1888 } 1943 }
1889 1944
1890 1945
1891 } } // namespace v8::internal 1946 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/stub-cache.h ('k') | src/token.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698