OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
195 if (!handler.is_null()) return handler; | 195 if (!handler.is_null()) return handler; |
196 | 196 |
197 LoadStubCompiler compiler(isolate_); | 197 LoadStubCompiler compiler(isolate_); |
198 handler = | 198 handler = |
199 compiler.CompileLoadNonexistent(receiver, current, cache_name, global); | 199 compiler.CompileLoadNonexistent(receiver, current, cache_name, global); |
200 HeapObject::UpdateMapCodeCache(receiver, cache_name, handler); | 200 HeapObject::UpdateMapCodeCache(receiver, cache_name, handler); |
201 return handler; | 201 return handler; |
202 } | 202 } |
203 | 203 |
204 | 204 |
205 Handle<Code> StubCache::ComputeLoadField(Handle<Name> name, | |
206 Handle<JSObject> receiver, | |
207 Handle<JSObject> holder, | |
208 PropertyIndex field, | |
209 Representation representation) { | |
210 if (receiver.is_identical_to(holder)) { | |
211 LoadFieldStub stub(field.is_inobject(holder), | |
212 field.translate(holder), | |
213 representation); | |
214 return stub.GetCode(isolate()); | |
215 } | |
216 | |
217 LoadStubCompiler compiler(isolate_); | |
218 return compiler.CompileLoadField( | |
219 receiver, holder, name, field, representation); | |
220 } | |
221 | |
222 | |
223 Handle<Code> StubCache::ComputeLoadCallback( | |
224 Handle<Name> name, | |
225 Handle<JSObject> receiver, | |
226 Handle<JSObject> holder, | |
227 Handle<ExecutableAccessorInfo> callback) { | |
228 ASSERT(v8::ToCData<Address>(callback->getter()) != 0); | |
229 LoadStubCompiler compiler(isolate_); | |
230 return compiler.CompileLoadCallback(receiver, holder, name, callback); | |
231 } | |
232 | |
233 | |
234 Handle<Code> StubCache::ComputeLoadCallback( | |
235 Handle<Name> name, | |
236 Handle<JSObject> receiver, | |
237 Handle<JSObject> holder, | |
238 const CallOptimization& call_optimization) { | |
239 LoadStubCompiler compiler(isolate_); | |
240 return compiler.CompileLoadCallback( | |
241 receiver, holder, name, call_optimization); | |
242 } | |
243 | |
244 | |
245 Handle<Code> StubCache::ComputeLoadViaGetter(Handle<Name> name, | |
246 Handle<JSObject> receiver, | |
247 Handle<JSObject> holder, | |
248 Handle<JSFunction> getter) { | |
249 LoadStubCompiler compiler(isolate_); | |
250 return compiler.CompileLoadViaGetter(receiver, holder, name, getter); | |
251 } | |
252 | |
253 | |
254 Handle<Code> StubCache::ComputeLoadConstant(Handle<Name> name, | |
255 Handle<JSObject> receiver, | |
256 Handle<JSObject> holder, | |
257 Handle<Object> value) { | |
258 LoadStubCompiler compiler(isolate_); | |
259 return compiler.CompileLoadConstant(receiver, holder, name, value); | |
260 } | |
261 | |
262 | |
263 Handle<Code> StubCache::ComputeLoadInterceptor(Handle<Name> name, | |
264 Handle<JSObject> receiver, | |
265 Handle<JSObject> holder) { | |
266 LoadStubCompiler compiler(isolate_); | |
267 return compiler.CompileLoadInterceptor(receiver, holder, name); | |
268 } | |
269 | |
270 | |
271 Handle<Code> StubCache::ComputeLoadNormal(Handle<Name> name, | |
272 Handle<JSObject> receiver) { | |
273 return isolate_->builtins()->LoadIC_Normal(); | |
274 } | |
275 | |
276 | |
277 Handle<Code> StubCache::ComputeLoadGlobal(Handle<Name> name, | 205 Handle<Code> StubCache::ComputeLoadGlobal(Handle<Name> name, |
278 Handle<JSObject> receiver, | 206 Handle<JSObject> receiver, |
279 Handle<GlobalObject> holder, | 207 Handle<GlobalObject> holder, |
280 Handle<PropertyCell> cell, | 208 Handle<PropertyCell> cell, |
281 bool is_dont_delete) { | 209 bool is_dont_delete) { |
282 Handle<Code> stub = FindIC(name, receiver, Code::LOAD_IC); | 210 Handle<Code> stub = FindIC(name, receiver, Code::LOAD_IC); |
283 if (!stub.is_null()) return stub; | 211 if (!stub.is_null()) return stub; |
284 | 212 |
285 LoadStubCompiler compiler(isolate_); | 213 LoadStubCompiler compiler(isolate_); |
286 Handle<Code> ic = | 214 Handle<Code> ic = |
287 compiler.CompileLoadGlobal(receiver, holder, cell, name, is_dont_delete); | 215 compiler.CompileLoadGlobal(receiver, holder, cell, name, is_dont_delete); |
288 HeapObject::UpdateMapCodeCache(receiver, name, ic); | 216 HeapObject::UpdateMapCodeCache(receiver, name, ic); |
289 return ic; | 217 return ic; |
290 } | 218 } |
291 | 219 |
292 | 220 |
293 Handle<Code> StubCache::ComputeKeyedLoadField(Handle<Name> name, | |
294 Handle<JSObject> receiver, | |
295 Handle<JSObject> holder, | |
296 PropertyIndex field, | |
297 Representation representation) { | |
298 if (receiver.is_identical_to(holder)) { | |
299 // TODO(titzer): this should use an HObjectAccess | |
300 KeyedLoadFieldStub stub(field.is_inobject(holder), | |
301 field.translate(holder), | |
302 representation); | |
303 return stub.GetCode(isolate()); | |
304 } | |
305 | |
306 KeyedLoadStubCompiler compiler(isolate_); | |
307 return compiler.CompileLoadField( | |
308 receiver, holder, name, field, representation); | |
309 } | |
310 | |
311 | |
312 Handle<Code> StubCache::ComputeKeyedLoadConstant(Handle<Name> name, | |
313 Handle<JSObject> receiver, | |
314 Handle<JSObject> holder, | |
315 Handle<Object> value) { | |
316 KeyedLoadStubCompiler compiler(isolate_); | |
317 return compiler.CompileLoadConstant( | |
318 receiver, holder, name, value); | |
319 } | |
320 | |
321 | |
322 Handle<Code> StubCache::ComputeKeyedLoadInterceptor(Handle<Name> name, | |
323 Handle<JSObject> receiver, | |
324 Handle<JSObject> holder) { | |
325 KeyedLoadStubCompiler compiler(isolate_); | |
326 return compiler.CompileLoadInterceptor(receiver, holder, name); | |
327 } | |
328 | |
329 | |
330 Handle<Code> StubCache::ComputeKeyedLoadCallback( | |
331 Handle<Name> name, | |
332 Handle<JSObject> receiver, | |
333 Handle<JSObject> holder, | |
334 Handle<ExecutableAccessorInfo> callback) { | |
335 KeyedLoadStubCompiler compiler(isolate_); | |
336 return compiler.CompileLoadCallback(receiver, holder, name, callback); | |
337 } | |
338 | |
339 | |
340 Handle<Code> StubCache::ComputeKeyedLoadCallback( | |
341 Handle<Name> name, | |
342 Handle<JSObject> receiver, | |
343 Handle<JSObject> holder, | |
344 const CallOptimization& call_optimization) { | |
345 KeyedLoadStubCompiler compiler(isolate_); | |
346 return compiler.CompileLoadCallback( | |
347 receiver, holder, name, call_optimization); | |
348 } | |
349 | |
350 | |
351 Handle<Code> StubCache::ComputeStoreField(Handle<Name> name, | |
352 Handle<JSObject> receiver, | |
353 LookupResult* lookup, | |
354 StrictModeFlag strict_mode) { | |
355 StoreStubCompiler compiler(isolate_, strict_mode); | |
356 return compiler.CompileStoreField(receiver, lookup, name); | |
357 } | |
358 | |
359 | |
360 Handle<Code> StubCache::ComputeStoreTransition(Handle<Name> name, | |
361 Handle<JSObject> receiver, | |
362 LookupResult* lookup, | |
363 Handle<Map> transition, | |
364 StrictModeFlag strict_mode) { | |
365 StoreStubCompiler compiler(isolate_, strict_mode); | |
366 return compiler.CompileStoreTransition(receiver, lookup, transition, name); | |
367 } | |
368 | |
369 | |
370 Handle<Code> StubCache::ComputeKeyedLoadElement(Handle<Map> receiver_map) { | 221 Handle<Code> StubCache::ComputeKeyedLoadElement(Handle<Map> receiver_map) { |
371 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC); | 222 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC); |
372 Handle<Name> name = | 223 Handle<Name> name = |
373 isolate()->factory()->KeyedLoadElementMonomorphic_string(); | 224 isolate()->factory()->KeyedLoadElementMonomorphic_string(); |
374 | 225 |
375 Handle<Object> probe(receiver_map->FindInCodeCache(*name, flags), isolate_); | 226 Handle<Object> probe(receiver_map->FindInCodeCache(*name, flags), isolate_); |
376 if (probe->IsCode()) return Handle<Code>::cast(probe); | 227 if (probe->IsCode()) return Handle<Code>::cast(probe); |
377 | 228 |
378 KeyedLoadStubCompiler compiler(isolate()); | 229 KeyedLoadStubCompiler compiler(isolate()); |
379 Handle<Code> code = compiler.CompileLoadElement(receiver_map); | 230 Handle<Code> code = compiler.CompileLoadElement(receiver_map); |
(...skipping 24 matching lines...) Expand all Loading... | |
404 | 255 |
405 KeyedStoreStubCompiler compiler(isolate(), strict_mode, store_mode); | 256 KeyedStoreStubCompiler compiler(isolate(), strict_mode, store_mode); |
406 Handle<Code> code = compiler.CompileStoreElement(receiver_map); | 257 Handle<Code> code = compiler.CompileStoreElement(receiver_map); |
407 | 258 |
408 Map::UpdateCodeCache(receiver_map, name, code); | 259 Map::UpdateCodeCache(receiver_map, name, code); |
409 ASSERT(Code::GetKeyedAccessStoreMode(code->extra_ic_state()) == store_mode); | 260 ASSERT(Code::GetKeyedAccessStoreMode(code->extra_ic_state()) == store_mode); |
410 return code; | 261 return code; |
411 } | 262 } |
412 | 263 |
413 | 264 |
414 Handle<Code> StubCache::ComputeStoreNormal(StrictModeFlag strict_mode) { | |
415 return (strict_mode == kStrictMode) | |
416 ? isolate_->builtins()->Builtins::StoreIC_Normal_Strict() | |
417 : isolate_->builtins()->Builtins::StoreIC_Normal(); | |
418 } | |
419 | |
420 | |
421 Handle<Code> StubCache::ComputeStoreGlobal(Handle<Name> name, | 265 Handle<Code> StubCache::ComputeStoreGlobal(Handle<Name> name, |
422 Handle<GlobalObject> receiver, | 266 Handle<GlobalObject> receiver, |
423 Handle<PropertyCell> cell, | 267 Handle<PropertyCell> cell, |
424 Handle<Object> value, | 268 Handle<Object> value, |
425 StrictModeFlag strict_mode) { | 269 StrictModeFlag strict_mode) { |
426 Isolate* isolate = cell->GetIsolate(); | 270 Isolate* isolate = cell->GetIsolate(); |
427 Handle<Type> union_type(PropertyCell::UpdateType(cell, value), isolate); | 271 Handle<Type> union_type(PropertyCell::UpdateType(cell, value), isolate); |
428 bool is_constant = union_type->IsConstant(); | 272 bool is_constant = union_type->IsConstant(); |
429 StoreGlobalStub stub(strict_mode, is_constant); | 273 StoreGlobalStub stub(strict_mode, is_constant); |
430 | 274 |
(...skipping 10 matching lines...) Expand all Loading... | |
441 code->ReplaceNthObject(1, *meta_map, *receiver_map); | 285 code->ReplaceNthObject(1, *meta_map, *receiver_map); |
442 Handle<Map> cell_map(isolate_->heap()->global_property_cell_map()); | 286 Handle<Map> cell_map(isolate_->heap()->global_property_cell_map()); |
443 code->ReplaceNthObject(1, *cell_map, *cell); | 287 code->ReplaceNthObject(1, *cell_map, *cell); |
444 | 288 |
445 HeapObject::UpdateMapCodeCache(receiver, name, code); | 289 HeapObject::UpdateMapCodeCache(receiver, name, code); |
446 | 290 |
447 return code; | 291 return code; |
448 } | 292 } |
449 | 293 |
450 | 294 |
451 Handle<Code> StubCache::ComputeStoreCallback( | |
452 Handle<Name> name, | |
453 Handle<JSObject> receiver, | |
454 Handle<JSObject> holder, | |
455 Handle<ExecutableAccessorInfo> callback, | |
456 StrictModeFlag strict_mode) { | |
457 ASSERT(v8::ToCData<Address>(callback->setter()) != 0); | |
458 StoreStubCompiler compiler(isolate_, strict_mode); | |
459 return compiler.CompileStoreCallback(receiver, holder, name, callback); | |
460 } | |
461 | |
462 | |
463 Handle<Code> StubCache::ComputeStoreCallback( | |
464 Handle<Name> name, | |
465 Handle<JSObject> receiver, | |
466 Handle<JSObject> holder, | |
467 const CallOptimization& call_optimization, | |
468 StrictModeFlag strict_mode) { | |
469 StoreStubCompiler compiler(isolate_, strict_mode); | |
470 return compiler.CompileStoreCallback( | |
471 receiver, holder, name, call_optimization); | |
472 } | |
473 | |
474 | |
475 Handle<Code> StubCache::ComputeStoreViaSetter(Handle<Name> name, | |
476 Handle<JSObject> receiver, | |
477 Handle<JSObject> holder, | |
478 Handle<JSFunction> setter, | |
479 StrictModeFlag strict_mode) { | |
480 StoreStubCompiler compiler(isolate_, strict_mode); | |
481 return compiler.CompileStoreViaSetter(receiver, holder, name, setter); | |
482 } | |
483 | |
484 | |
485 Handle<Code> StubCache::ComputeStoreInterceptor(Handle<Name> name, | |
486 Handle<JSObject> receiver, | |
487 StrictModeFlag strict_mode) { | |
488 StoreStubCompiler compiler(isolate_, strict_mode); | |
489 return compiler.CompileStoreInterceptor(receiver, name); | |
490 } | |
491 | |
492 | |
493 Handle<Code> StubCache::ComputeKeyedStoreField(Handle<Name> name, | |
494 Handle<JSObject> receiver, | |
495 LookupResult* lookup, | |
496 StrictModeFlag strict_mode) { | |
497 KeyedStoreStubCompiler compiler(isolate(), strict_mode, STANDARD_STORE); | |
498 return compiler.CompileStoreField(receiver, lookup, name); | |
499 } | |
500 | |
501 | |
502 Handle<Code> StubCache::ComputeKeyedStoreTransition( | |
503 Handle<Name> name, | |
504 Handle<JSObject> receiver, | |
505 LookupResult* lookup, | |
506 Handle<Map> transition, | |
507 StrictModeFlag strict_mode) { | |
508 KeyedStoreStubCompiler compiler(isolate(), strict_mode, STANDARD_STORE); | |
509 return compiler.CompileStoreTransition(receiver, lookup, transition, name); | |
510 } | |
511 | |
512 | |
513 #define CALL_LOGGER_TAG(kind, type) \ | 295 #define CALL_LOGGER_TAG(kind, type) \ |
514 (kind == Code::CALL_IC ? Logger::type : Logger::KEYED_##type) | 296 (kind == Code::CALL_IC ? Logger::type : Logger::KEYED_##type) |
515 | 297 |
516 Handle<Code> StubCache::ComputeCallConstant(int argc, | 298 Handle<Code> StubCache::ComputeCallConstant(int argc, |
517 Code::Kind kind, | 299 Code::Kind kind, |
518 Code::ExtraICState extra_state, | 300 Code::ExtraICState extra_state, |
519 Handle<Name> name, | 301 Handle<Name> name, |
520 Handle<Object> object, | 302 Handle<Object> object, |
521 Handle<JSObject> holder, | 303 Handle<JSObject> holder, |
522 Handle<JSFunction> function) { | 304 Handle<JSFunction> function) { |
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1380 holder->LocalLookupRealNamedProperty(*name, lookup); | 1162 holder->LocalLookupRealNamedProperty(*name, lookup); |
1381 if (lookup->IsFound()) return; | 1163 if (lookup->IsFound()) return; |
1382 if (holder->GetPrototype()->IsNull()) return; | 1164 if (holder->GetPrototype()->IsNull()) return; |
1383 holder->GetPrototype()->Lookup(*name, lookup); | 1165 holder->GetPrototype()->Lookup(*name, lookup); |
1384 } | 1166 } |
1385 | 1167 |
1386 | 1168 |
1387 #define __ ACCESS_MASM(masm()) | 1169 #define __ ACCESS_MASM(masm()) |
1388 | 1170 |
1389 | 1171 |
1390 Register BaseLoadStubCompiler::HandlerFrontendHeader( | 1172 Register LoadStubCompiler::HandlerFrontendHeader( |
1391 Handle<JSObject> object, | 1173 Handle<JSObject> object, |
1392 Register object_reg, | 1174 Register object_reg, |
1393 Handle<JSObject> holder, | 1175 Handle<JSObject> holder, |
1394 Handle<Name> name, | 1176 Handle<Name> name, |
1395 Label* miss) { | 1177 Label* miss) { |
1396 return CheckPrototypes(object, object_reg, holder, | 1178 return CheckPrototypes(object, object_reg, holder, |
1397 scratch1(), scratch2(), scratch3(), | 1179 scratch1(), scratch2(), scratch3(), |
1398 name, miss, SKIP_RECEIVER); | 1180 name, miss, SKIP_RECEIVER); |
1399 } | 1181 } |
1400 | 1182 |
1401 | 1183 |
1402 // HandlerFrontend for store uses the name register. It has to be restored | 1184 // HandlerFrontend for store uses the name register. It has to be restored |
1403 // before a miss. | 1185 // before a miss. |
1404 Register BaseStoreStubCompiler::HandlerFrontendHeader( | 1186 Register StoreStubCompiler::HandlerFrontendHeader( |
1405 Handle<JSObject> object, | 1187 Handle<JSObject> object, |
1406 Register object_reg, | 1188 Register object_reg, |
1407 Handle<JSObject> holder, | 1189 Handle<JSObject> holder, |
1408 Handle<Name> name, | 1190 Handle<Name> name, |
1409 Label* miss) { | 1191 Label* miss) { |
1410 return CheckPrototypes(object, object_reg, holder, | 1192 return CheckPrototypes(object, object_reg, holder, |
1411 this->name(), scratch1(), scratch2(), | 1193 this->name(), scratch1(), scratch2(), |
1412 name, miss, SKIP_RECEIVER); | 1194 name, miss, SKIP_RECEIVER); |
1413 } | 1195 } |
1414 | 1196 |
1415 | 1197 |
1416 Register BaseLoadStoreStubCompiler::HandlerFrontend(Handle<JSObject> object, | 1198 Register BaseLoadStoreStubCompiler::HandlerFrontend(Handle<JSObject> object, |
1417 Register object_reg, | 1199 Register object_reg, |
1418 Handle<JSObject> holder, | 1200 Handle<JSObject> holder, |
1419 Handle<Name> name, | 1201 Handle<Name> name, |
1420 Label* success) { | 1202 Label* success) { |
1421 Label miss; | 1203 Label miss; |
1422 | 1204 |
1423 Register reg = HandlerFrontendHeader(object, object_reg, holder, name, &miss); | 1205 Register reg = HandlerFrontendHeader(object, object_reg, holder, name, &miss); |
1424 | 1206 |
1425 HandlerFrontendFooter(name, success, &miss); | 1207 HandlerFrontendFooter(name, success, &miss); |
1426 return reg; | 1208 return reg; |
1427 } | 1209 } |
1428 | 1210 |
1429 | 1211 |
1430 Handle<Code> BaseLoadStubCompiler::CompileLoadField( | 1212 Handle<Code> LoadStubCompiler::CompileLoadField( |
1431 Handle<JSObject> object, | 1213 Handle<JSObject> object, |
1432 Handle<JSObject> holder, | 1214 Handle<JSObject> holder, |
1433 Handle<Name> name, | 1215 Handle<Name> name, |
1434 PropertyIndex field, | 1216 PropertyIndex field, |
1435 Representation representation) { | 1217 Representation representation) { |
1436 Label miss; | 1218 Label miss; |
1437 | 1219 |
1438 Register reg = HandlerFrontendHeader(object, receiver(), holder, name, &miss); | 1220 Register reg = HandlerFrontendHeader(object, receiver(), holder, name, &miss); |
1439 | 1221 |
1440 GenerateLoadField(reg, holder, field, representation); | 1222 GenerateLoadField(reg, holder, field, representation); |
1441 | 1223 |
1442 __ bind(&miss); | 1224 __ bind(&miss); |
1443 TailCallBuiltin(masm(), MissBuiltin(kind())); | 1225 TailCallBuiltin(masm(), MissBuiltin(kind())); |
1444 | 1226 |
1445 // Return the generated code. | 1227 // Return the generated code. |
1446 return GetCode(kind(), Code::FIELD, name); | 1228 return GetCode(kind(), Code::FIELD, name); |
1447 } | 1229 } |
1448 | 1230 |
1449 | 1231 |
1450 Handle<Code> BaseLoadStubCompiler::CompileLoadConstant( | 1232 Handle<Code> LoadStubCompiler::CompileLoadConstant( |
1451 Handle<JSObject> object, | 1233 Handle<JSObject> object, |
1452 Handle<JSObject> holder, | 1234 Handle<JSObject> holder, |
1453 Handle<Name> name, | 1235 Handle<Name> name, |
1454 Handle<Object> value) { | 1236 Handle<Object> value) { |
1455 Label success; | 1237 Label success; |
1456 HandlerFrontend(object, receiver(), holder, name, &success); | 1238 HandlerFrontend(object, receiver(), holder, name, &success); |
1457 __ bind(&success); | 1239 __ bind(&success); |
1458 GenerateLoadConstant(value); | 1240 GenerateLoadConstant(value); |
1459 | 1241 |
1460 // Return the generated code. | 1242 // Return the generated code. |
1461 return GetCode(kind(), Code::CONSTANT, name); | 1243 return GetCode(kind(), Code::CONSTANT, name); |
1462 } | 1244 } |
1463 | 1245 |
1464 | 1246 |
1465 Handle<Code> BaseLoadStubCompiler::CompileLoadCallback( | 1247 Handle<Code> LoadStubCompiler::CompileLoadCallback( |
1466 Handle<JSObject> object, | 1248 Handle<JSObject> object, |
1467 Handle<JSObject> holder, | 1249 Handle<JSObject> holder, |
1468 Handle<Name> name, | 1250 Handle<Name> name, |
1469 Handle<ExecutableAccessorInfo> callback) { | 1251 Handle<ExecutableAccessorInfo> callback) { |
1470 Label success; | 1252 Label success; |
1471 | 1253 |
1472 Register reg = CallbackHandlerFrontend( | 1254 Register reg = CallbackHandlerFrontend( |
1473 object, receiver(), holder, name, &success, callback); | 1255 object, receiver(), holder, name, &success, callback); |
1474 __ bind(&success); | 1256 __ bind(&success); |
1475 GenerateLoadCallback(reg, callback); | 1257 GenerateLoadCallback(reg, callback); |
1476 | 1258 |
1477 // Return the generated code. | 1259 // Return the generated code. |
1478 return GetCode(kind(), Code::CALLBACKS, name); | 1260 return GetCode(kind(), Code::CALLBACKS, name); |
1479 } | 1261 } |
1480 | 1262 |
1481 | 1263 |
1482 Handle<Code> BaseLoadStubCompiler::CompileLoadCallback( | 1264 Handle<Code> LoadStubCompiler::CompileLoadCallback( |
1483 Handle<JSObject> object, | 1265 Handle<JSObject> object, |
1484 Handle<JSObject> holder, | 1266 Handle<JSObject> holder, |
1485 Handle<Name> name, | 1267 Handle<Name> name, |
1486 const CallOptimization& call_optimization) { | 1268 const CallOptimization& call_optimization) { |
1487 ASSERT(call_optimization.is_simple_api_call()); | 1269 ASSERT(call_optimization.is_simple_api_call()); |
1488 Label success; | 1270 Label success; |
1489 | 1271 |
1490 Handle<JSFunction> callback = call_optimization.constant_function(); | 1272 Handle<JSFunction> callback = call_optimization.constant_function(); |
1491 CallbackHandlerFrontend( | 1273 CallbackHandlerFrontend( |
1492 object, receiver(), holder, name, &success, callback); | 1274 object, receiver(), holder, name, &success, callback); |
1493 __ bind(&success); | 1275 __ bind(&success); |
1494 GenerateLoadCallback(call_optimization); | 1276 GenerateLoadCallback(call_optimization); |
1495 | 1277 |
1496 // Return the generated code. | 1278 // Return the generated code. |
1497 return GetCode(kind(), Code::CALLBACKS, name); | 1279 return GetCode(kind(), Code::CALLBACKS, name); |
1498 } | 1280 } |
1499 | 1281 |
1500 | 1282 |
1501 Handle<Code> BaseLoadStubCompiler::CompileLoadInterceptor( | 1283 Handle<Code> LoadStubCompiler::CompileLoadInterceptor( |
1502 Handle<JSObject> object, | 1284 Handle<JSObject> object, |
1503 Handle<JSObject> holder, | 1285 Handle<JSObject> holder, |
1504 Handle<Name> name) { | 1286 Handle<Name> name) { |
1505 Label success; | 1287 Label success; |
1506 | 1288 |
1507 LookupResult lookup(isolate()); | 1289 LookupResult lookup(isolate()); |
1508 LookupPostInterceptor(holder, name, &lookup); | 1290 LookupPostInterceptor(holder, name, &lookup); |
1509 | 1291 |
1510 Register reg = HandlerFrontend(object, receiver(), holder, name, &success); | 1292 Register reg = HandlerFrontend(object, receiver(), holder, name, &success); |
1511 __ bind(&success); | 1293 __ bind(&success); |
1512 // TODO(368): Compile in the whole chain: all the interceptors in | 1294 // TODO(368): Compile in the whole chain: all the interceptors in |
1513 // prototypes and ultimate answer. | 1295 // prototypes and ultimate answer. |
1514 GenerateLoadInterceptor(reg, object, holder, &lookup, name); | 1296 GenerateLoadInterceptor(reg, object, holder, &lookup, name); |
1515 | 1297 |
1516 // Return the generated code. | 1298 // Return the generated code. |
1517 return GetCode(kind(), Code::INTERCEPTOR, name); | 1299 return GetCode(kind(), Code::INTERCEPTOR, name); |
1518 } | 1300 } |
1519 | 1301 |
1520 | 1302 |
1521 void BaseLoadStubCompiler::GenerateLoadPostInterceptor( | 1303 void LoadStubCompiler::GenerateLoadPostInterceptor( |
1522 Register interceptor_reg, | 1304 Register interceptor_reg, |
1523 Handle<JSObject> interceptor_holder, | 1305 Handle<JSObject> interceptor_holder, |
1524 Handle<Name> name, | 1306 Handle<Name> name, |
1525 LookupResult* lookup) { | 1307 LookupResult* lookup) { |
1526 Label success; | 1308 Label success; |
1527 Handle<JSObject> holder(lookup->holder()); | 1309 Handle<JSObject> holder(lookup->holder()); |
1528 if (lookup->IsField()) { | 1310 if (lookup->IsField()) { |
1529 PropertyIndex field = lookup->GetFieldIndex(); | 1311 PropertyIndex field = lookup->GetFieldIndex(); |
1530 if (interceptor_holder.is_identical_to(holder)) { | 1312 if (interceptor_holder.is_identical_to(holder)) { |
1531 GenerateLoadField( | 1313 GenerateLoadField( |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1570 | 1352 |
1571 Handle<Code> LoadStubCompiler::CompileLoadViaGetter( | 1353 Handle<Code> LoadStubCompiler::CompileLoadViaGetter( |
1572 Handle<JSObject> object, | 1354 Handle<JSObject> object, |
1573 Handle<JSObject> holder, | 1355 Handle<JSObject> holder, |
1574 Handle<Name> name, | 1356 Handle<Name> name, |
1575 Handle<JSFunction> getter) { | 1357 Handle<JSFunction> getter) { |
1576 Label success; | 1358 Label success; |
1577 HandlerFrontend(object, receiver(), holder, name, &success); | 1359 HandlerFrontend(object, receiver(), holder, name, &success); |
1578 | 1360 |
1579 __ bind(&success); | 1361 __ bind(&success); |
1580 GenerateLoadViaGetter(masm(), getter); | 1362 GenerateLoadViaGetter(masm(), receiver(), getter); |
1581 | 1363 |
1582 // Return the generated code. | 1364 // Return the generated code. |
1583 return GetCode(kind(), Code::CALLBACKS, name); | 1365 return GetCode(kind(), Code::CALLBACKS, name); |
1584 } | 1366 } |
1585 | 1367 |
1586 | 1368 |
1587 Handle<Code> BaseStoreStubCompiler::CompileStoreTransition( | 1369 Handle<Code> StoreStubCompiler::CompileStoreTransition( |
1588 Handle<JSObject> object, | 1370 Handle<JSObject> object, |
1589 LookupResult* lookup, | 1371 LookupResult* lookup, |
1590 Handle<Map> transition, | 1372 Handle<Map> transition, |
1591 Handle<Name> name) { | 1373 Handle<Name> name) { |
1592 Label miss, slow; | 1374 Label miss, slow; |
1593 | 1375 |
1594 // Ensure no transitions to deprecated maps are followed. | 1376 // Ensure no transitions to deprecated maps are followed. |
1595 __ CheckMapDeprecated(transition, scratch1(), &miss); | 1377 __ CheckMapDeprecated(transition, scratch1(), &miss); |
1596 | 1378 |
1597 // Check that we are allowed to write this. | 1379 // Check that we are allowed to write this. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1634 TailCallBuiltin(masm(), MissBuiltin(kind())); | 1416 TailCallBuiltin(masm(), MissBuiltin(kind())); |
1635 | 1417 |
1636 GenerateRestoreName(masm(), &slow, name); | 1418 GenerateRestoreName(masm(), &slow, name); |
1637 TailCallBuiltin(masm(), SlowBuiltin(kind())); | 1419 TailCallBuiltin(masm(), SlowBuiltin(kind())); |
1638 | 1420 |
1639 // Return the generated code. | 1421 // Return the generated code. |
1640 return GetCode(kind(), Code::TRANSITION, name); | 1422 return GetCode(kind(), Code::TRANSITION, name); |
1641 } | 1423 } |
1642 | 1424 |
1643 | 1425 |
1644 Handle<Code> BaseStoreStubCompiler::CompileStoreField(Handle<JSObject> object, | 1426 Handle<Code> StoreStubCompiler::CompileStoreField(Handle<JSObject> object, |
1645 LookupResult* lookup, | 1427 LookupResult* lookup, |
1646 Handle<Name> name) { | 1428 Handle<Name> name) { |
1647 Label miss; | 1429 Label miss; |
1648 | 1430 |
1649 HandlerFrontendHeader(object, receiver(), object, name, &miss); | 1431 HandlerFrontendHeader(object, receiver(), object, name, &miss); |
1650 | 1432 |
1651 // Generate store field code. | 1433 // Generate store field code. |
1652 GenerateStoreField(masm(), | 1434 GenerateStoreField(masm(), |
1653 object, | 1435 object, |
1654 lookup, | 1436 lookup, |
1655 receiver(), this->name(), value(), scratch1(), scratch2(), | 1437 receiver(), this->name(), value(), scratch1(), scratch2(), |
1656 &miss); | 1438 &miss); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1729 | 1511 |
1730 #undef __ | 1512 #undef __ |
1731 | 1513 |
1732 | 1514 |
1733 void StubCompiler::TailCallBuiltin(MacroAssembler* masm, Builtins::Name name) { | 1515 void StubCompiler::TailCallBuiltin(MacroAssembler* masm, Builtins::Name name) { |
1734 Handle<Code> code(masm->isolate()->builtins()->builtin(name)); | 1516 Handle<Code> code(masm->isolate()->builtins()->builtin(name)); |
1735 GenerateTailCall(masm, code); | 1517 GenerateTailCall(masm, code); |
1736 } | 1518 } |
1737 | 1519 |
1738 | 1520 |
1739 void LoadStubCompiler::JitEvent(Handle<Name> name, Handle<Code> code) { | 1521 void BaseLoadStoreStubCompiler::JitEvent(Handle<Name> name, Handle<Code> code) { |
1740 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, *name, *code)); | 1522 #ifdef ENABLE_GDB_JIT_INTERFACE |
1523 GDBJITInterface::CodeTag tag; | |
1524 if (kind_ == Code::LOAD_IC) { | |
ulan
2013/10/11 13:37:51
I'd prefer "switch" here, but feel free to leave a
| |
1525 tag = GDBJITInterface::LOAD_IC; | |
1526 } else if (kind_ == Code::KEYED_LOAD_IC) { | |
1527 tag = GDBJITInterface::KEYED_LOAD_IC; | |
1528 } else if (kind_ == Code::STORE_IC) { | |
1529 tag = GDBJITInterface::STORE_IC; | |
1530 } else { | |
1531 tag = GDBJITInterface::KEYED_STORE_IC; | |
1532 } | |
1533 GDBJIT(AddCode(tag, *name, *code)); | |
1534 #endif | |
1741 } | 1535 } |
1742 | 1536 |
1743 | 1537 |
1744 void KeyedLoadStubCompiler::JitEvent(Handle<Name> name, Handle<Code> code) { | 1538 void BaseLoadStoreStubCompiler::InitializeRegisters() { |
1745 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, *name, *code)); | 1539 if (kind_ == Code::LOAD_IC) { |
1540 registers_ = LoadStubCompiler::registers(); | |
1541 } else if (kind_ == Code::KEYED_LOAD_IC) { | |
1542 registers_ = KeyedLoadStubCompiler::registers(); | |
1543 } else if (kind_ == Code::STORE_IC) { | |
1544 registers_ = StoreStubCompiler::registers(); | |
1545 } else { | |
1546 registers_ = KeyedStoreStubCompiler::registers(); | |
1547 } | |
1746 } | 1548 } |
1747 | 1549 |
1748 | 1550 |
1749 void StoreStubCompiler::JitEvent(Handle<Name> name, Handle<Code> code) { | |
1750 GDBJIT(AddCode(GDBJITInterface::STORE_IC, *name, *code)); | |
1751 } | |
1752 | |
1753 | |
1754 void KeyedStoreStubCompiler::JitEvent(Handle<Name> name, Handle<Code> code) { | |
1755 GDBJIT(AddCode(GDBJITInterface::KEYED_STORE_IC, *name, *code)); | |
1756 } | |
1757 | |
1758 | |
1759 Handle<Code> BaseLoadStoreStubCompiler::GetICCode(Code::Kind kind, | 1551 Handle<Code> BaseLoadStoreStubCompiler::GetICCode(Code::Kind kind, |
1760 Code::StubType type, | 1552 Code::StubType type, |
1761 Handle<Name> name, | 1553 Handle<Name> name, |
1762 InlineCacheState state) { | 1554 InlineCacheState state) { |
1763 Code::Flags flags = Code::ComputeFlags(kind, state, extra_state(), type); | 1555 Code::Flags flags = Code::ComputeFlags(kind, state, extra_state(), type); |
1764 Handle<Code> code = GetCodeWithFlags(flags, name); | 1556 Handle<Code> code = GetCodeWithFlags(flags, name); |
1765 PROFILE(isolate(), CodeCreateEvent(log_kind(code), *code, *name)); | 1557 PROFILE(isolate(), CodeCreateEvent(log_kind(code), *code, *name)); |
1766 JitEvent(name, code); | 1558 JitEvent(name, code); |
1767 return code; | 1559 return code; |
1768 } | 1560 } |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2026 Handle<FunctionTemplateInfo>( | 1818 Handle<FunctionTemplateInfo>( |
2027 FunctionTemplateInfo::cast(signature->receiver())); | 1819 FunctionTemplateInfo::cast(signature->receiver())); |
2028 } | 1820 } |
2029 } | 1821 } |
2030 | 1822 |
2031 is_simple_api_call_ = true; | 1823 is_simple_api_call_ = true; |
2032 } | 1824 } |
2033 | 1825 |
2034 | 1826 |
2035 } } // namespace v8::internal | 1827 } } // namespace v8::internal |
OLD | NEW |