OLD | NEW |
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 1237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1248 } | 1248 } |
1249 | 1249 |
1250 | 1250 |
1251 Object* StoreStubCompiler::CompileStoreField(JSObject* object, | 1251 Object* StoreStubCompiler::CompileStoreField(JSObject* object, |
1252 int index, | 1252 int index, |
1253 Map* transition, | 1253 Map* transition, |
1254 String* name) { | 1254 String* name) { |
1255 // ----------- S t a t e ------------- | 1255 // ----------- S t a t e ------------- |
1256 // -- eax : value | 1256 // -- eax : value |
1257 // -- ecx : name | 1257 // -- ecx : name |
| 1258 // -- edx : receiver |
1258 // -- esp[0] : return address | 1259 // -- esp[0] : return address |
1259 // -- esp[4] : receiver | |
1260 // ----------------------------------- | 1260 // ----------------------------------- |
1261 Label miss; | 1261 Label miss; |
1262 | 1262 |
1263 // Get the object from the stack. | |
1264 __ mov(ebx, Operand(esp, 1 * kPointerSize)); | |
1265 | |
1266 // Generate store field code. Trashes the name register. | 1263 // Generate store field code. Trashes the name register. |
1267 GenerateStoreField(masm(), | 1264 GenerateStoreField(masm(), |
1268 Builtins::StoreIC_ExtendStorage, | 1265 Builtins::StoreIC_ExtendStorage, |
1269 object, | 1266 object, |
1270 index, | 1267 index, |
1271 transition, | 1268 transition, |
1272 ebx, ecx, edx, | 1269 edx, ecx, ebx, |
1273 &miss); | 1270 &miss); |
1274 | 1271 |
1275 // Handle store cache miss. | 1272 // Handle store cache miss. |
1276 __ bind(&miss); | 1273 __ bind(&miss); |
1277 __ mov(ecx, Immediate(Handle<String>(name))); // restore name | 1274 __ mov(ecx, Immediate(Handle<String>(name))); // restore name |
1278 Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Miss)); | 1275 Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Miss)); |
1279 __ jmp(ic, RelocInfo::CODE_TARGET); | 1276 __ jmp(ic, RelocInfo::CODE_TARGET); |
1280 | 1277 |
1281 // Return the generated code. | 1278 // Return the generated code. |
1282 return GetCode(transition == NULL ? FIELD : MAP_TRANSITION, name); | 1279 return GetCode(transition == NULL ? FIELD : MAP_TRANSITION, name); |
1283 } | 1280 } |
1284 | 1281 |
1285 | 1282 |
1286 Object* StoreStubCompiler::CompileStoreCallback(JSObject* object, | 1283 Object* StoreStubCompiler::CompileStoreCallback(JSObject* object, |
1287 AccessorInfo* callback, | 1284 AccessorInfo* callback, |
1288 String* name) { | 1285 String* name) { |
1289 // ----------- S t a t e ------------- | 1286 // ----------- S t a t e ------------- |
1290 // -- eax : value | 1287 // -- eax : value |
1291 // -- ecx : name | 1288 // -- ecx : name |
| 1289 // -- edx : receiver |
1292 // -- esp[0] : return address | 1290 // -- esp[0] : return address |
1293 // -- esp[4] : receiver | |
1294 // ----------------------------------- | 1291 // ----------------------------------- |
1295 Label miss; | 1292 Label miss; |
1296 | 1293 |
1297 // Get the object from the stack. | |
1298 __ mov(ebx, Operand(esp, 1 * kPointerSize)); | |
1299 | |
1300 // Check that the object isn't a smi. | 1294 // Check that the object isn't a smi. |
1301 __ test(ebx, Immediate(kSmiTagMask)); | 1295 __ test(edx, Immediate(kSmiTagMask)); |
1302 __ j(zero, &miss, not_taken); | 1296 __ j(zero, &miss, not_taken); |
1303 | 1297 |
1304 // Check that the map of the object hasn't changed. | 1298 // Check that the map of the object hasn't changed. |
1305 __ cmp(FieldOperand(ebx, HeapObject::kMapOffset), | 1299 __ cmp(FieldOperand(edx, HeapObject::kMapOffset), |
1306 Immediate(Handle<Map>(object->map()))); | 1300 Immediate(Handle<Map>(object->map()))); |
1307 __ j(not_equal, &miss, not_taken); | 1301 __ j(not_equal, &miss, not_taken); |
1308 | 1302 |
1309 // Perform global security token check if needed. | 1303 // Perform global security token check if needed. |
1310 if (object->IsJSGlobalProxy()) { | 1304 if (object->IsJSGlobalProxy()) { |
1311 __ CheckAccessGlobalProxy(ebx, edx, &miss); | 1305 __ CheckAccessGlobalProxy(edx, ebx, &miss); |
1312 } | 1306 } |
1313 | 1307 |
1314 // Stub never generated for non-global objects that require access | 1308 // Stub never generated for non-global objects that require access |
1315 // checks. | 1309 // checks. |
1316 ASSERT(object->IsJSGlobalProxy() || !object->IsAccessCheckNeeded()); | 1310 ASSERT(object->IsJSGlobalProxy() || !object->IsAccessCheckNeeded()); |
1317 | 1311 |
1318 __ pop(ebx); // remove the return address | 1312 __ pop(ebx); // remove the return address |
1319 __ push(Operand(esp, 0)); // receiver | 1313 __ push(edx); // receiver |
1320 __ push(Immediate(Handle<AccessorInfo>(callback))); // callback info | 1314 __ push(Immediate(Handle<AccessorInfo>(callback))); // callback info |
1321 __ push(ecx); // name | 1315 __ push(ecx); // name |
1322 __ push(eax); // value | 1316 __ push(eax); // value |
1323 __ push(ebx); // restore return address | 1317 __ push(ebx); // restore return address |
1324 | 1318 |
1325 // Do tail-call to the runtime system. | 1319 // Do tail-call to the runtime system. |
1326 ExternalReference store_callback_property = | 1320 ExternalReference store_callback_property = |
1327 ExternalReference(IC_Utility(IC::kStoreCallbackProperty)); | 1321 ExternalReference(IC_Utility(IC::kStoreCallbackProperty)); |
1328 __ TailCallRuntime(store_callback_property, 4, 1); | 1322 __ TailCallRuntime(store_callback_property, 4, 1); |
1329 | 1323 |
1330 // Handle store cache miss. | 1324 // Handle store cache miss. |
1331 __ bind(&miss); | 1325 __ bind(&miss); |
1332 Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Miss)); | 1326 Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Miss)); |
1333 __ jmp(ic, RelocInfo::CODE_TARGET); | 1327 __ jmp(ic, RelocInfo::CODE_TARGET); |
1334 | 1328 |
1335 // Return the generated code. | 1329 // Return the generated code. |
1336 return GetCode(CALLBACKS, name); | 1330 return GetCode(CALLBACKS, name); |
1337 } | 1331 } |
1338 | 1332 |
1339 | 1333 |
1340 Object* StoreStubCompiler::CompileStoreInterceptor(JSObject* receiver, | 1334 Object* StoreStubCompiler::CompileStoreInterceptor(JSObject* receiver, |
1341 String* name) { | 1335 String* name) { |
1342 // ----------- S t a t e ------------- | 1336 // ----------- S t a t e ------------- |
1343 // -- eax : value | 1337 // -- eax : value |
1344 // -- ecx : name | 1338 // -- ecx : name |
| 1339 // -- edx : receiver |
1345 // -- esp[0] : return address | 1340 // -- esp[0] : return address |
1346 // -- esp[4] : receiver | |
1347 // ----------------------------------- | 1341 // ----------------------------------- |
1348 Label miss; | 1342 Label miss; |
1349 | 1343 |
1350 // Get the object from the stack. | |
1351 __ mov(ebx, Operand(esp, 1 * kPointerSize)); | |
1352 | |
1353 // Check that the object isn't a smi. | 1344 // Check that the object isn't a smi. |
1354 __ test(ebx, Immediate(kSmiTagMask)); | 1345 __ test(edx, Immediate(kSmiTagMask)); |
1355 __ j(zero, &miss, not_taken); | 1346 __ j(zero, &miss, not_taken); |
1356 | 1347 |
1357 // Check that the map of the object hasn't changed. | 1348 // Check that the map of the object hasn't changed. |
1358 __ cmp(FieldOperand(ebx, HeapObject::kMapOffset), | 1349 __ cmp(FieldOperand(edx, HeapObject::kMapOffset), |
1359 Immediate(Handle<Map>(receiver->map()))); | 1350 Immediate(Handle<Map>(receiver->map()))); |
1360 __ j(not_equal, &miss, not_taken); | 1351 __ j(not_equal, &miss, not_taken); |
1361 | 1352 |
1362 // Perform global security token check if needed. | 1353 // Perform global security token check if needed. |
1363 if (receiver->IsJSGlobalProxy()) { | 1354 if (receiver->IsJSGlobalProxy()) { |
1364 __ CheckAccessGlobalProxy(ebx, edx, &miss); | 1355 __ CheckAccessGlobalProxy(edx, ebx, &miss); |
1365 } | 1356 } |
1366 | 1357 |
1367 // Stub never generated for non-global objects that require access | 1358 // Stub never generated for non-global objects that require access |
1368 // checks. | 1359 // checks. |
1369 ASSERT(receiver->IsJSGlobalProxy() || !receiver->IsAccessCheckNeeded()); | 1360 ASSERT(receiver->IsJSGlobalProxy() || !receiver->IsAccessCheckNeeded()); |
1370 | 1361 |
1371 __ pop(ebx); // remove the return address | 1362 __ pop(ebx); // remove the return address |
1372 __ push(Operand(esp, 0)); // receiver | 1363 __ push(edx); // receiver |
1373 __ push(ecx); // name | 1364 __ push(ecx); // name |
1374 __ push(eax); // value | 1365 __ push(eax); // value |
1375 __ push(ebx); // restore return address | 1366 __ push(ebx); // restore return address |
1376 | 1367 |
1377 // Do tail-call to the runtime system. | 1368 // Do tail-call to the runtime system. |
1378 ExternalReference store_ic_property = | 1369 ExternalReference store_ic_property = |
1379 ExternalReference(IC_Utility(IC::kStoreInterceptorProperty)); | 1370 ExternalReference(IC_Utility(IC::kStoreInterceptorProperty)); |
1380 __ TailCallRuntime(store_ic_property, 3, 1); | 1371 __ TailCallRuntime(store_ic_property, 3, 1); |
1381 | 1372 |
1382 // Handle store cache miss. | 1373 // Handle store cache miss. |
1383 __ bind(&miss); | 1374 __ bind(&miss); |
1384 Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Miss)); | 1375 Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Miss)); |
1385 __ jmp(ic, RelocInfo::CODE_TARGET); | 1376 __ jmp(ic, RelocInfo::CODE_TARGET); |
1386 | 1377 |
1387 // Return the generated code. | 1378 // Return the generated code. |
1388 return GetCode(INTERCEPTOR, name); | 1379 return GetCode(INTERCEPTOR, name); |
1389 } | 1380 } |
1390 | 1381 |
1391 | 1382 |
1392 Object* StoreStubCompiler::CompileStoreGlobal(GlobalObject* object, | 1383 Object* StoreStubCompiler::CompileStoreGlobal(GlobalObject* object, |
1393 JSGlobalPropertyCell* cell, | 1384 JSGlobalPropertyCell* cell, |
1394 String* name) { | 1385 String* name) { |
1395 // ----------- S t a t e ------------- | 1386 // ----------- S t a t e ------------- |
1396 // -- eax : value | 1387 // -- eax : value |
1397 // -- ecx : name | 1388 // -- ecx : name |
| 1389 // -- edx : receiver |
1398 // -- esp[0] : return address | 1390 // -- esp[0] : return address |
1399 // -- esp[4] : receiver | |
1400 // ----------------------------------- | 1391 // ----------------------------------- |
1401 Label miss; | 1392 Label miss; |
1402 | 1393 |
1403 // Check that the map of the global has not changed. | 1394 // Check that the map of the global has not changed. |
1404 __ mov(ebx, Operand(esp, kPointerSize)); | 1395 __ cmp(FieldOperand(edx, HeapObject::kMapOffset), |
1405 __ cmp(FieldOperand(ebx, HeapObject::kMapOffset), | |
1406 Immediate(Handle<Map>(object->map()))); | 1396 Immediate(Handle<Map>(object->map()))); |
1407 __ j(not_equal, &miss, not_taken); | 1397 __ j(not_equal, &miss, not_taken); |
1408 | 1398 |
1409 // Store the value in the cell. | 1399 // Store the value in the cell. |
1410 __ mov(ecx, Immediate(Handle<JSGlobalPropertyCell>(cell))); | 1400 __ mov(ecx, Immediate(Handle<JSGlobalPropertyCell>(cell))); |
1411 __ mov(FieldOperand(ecx, JSGlobalPropertyCell::kValueOffset), eax); | 1401 __ mov(FieldOperand(ecx, JSGlobalPropertyCell::kValueOffset), eax); |
1412 | 1402 |
1413 // Return the value (register eax). | 1403 // Return the value (register eax). |
1414 __ IncrementCounter(&Counters::named_store_global_inline, 1); | 1404 __ IncrementCounter(&Counters::named_store_global_inline, 1); |
1415 __ ret(0); | 1405 __ ret(0); |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1965 __ jmp(generic_construct_stub, RelocInfo::CODE_TARGET); | 1955 __ jmp(generic_construct_stub, RelocInfo::CODE_TARGET); |
1966 | 1956 |
1967 // Return the generated code. | 1957 // Return the generated code. |
1968 return GetCode(); | 1958 return GetCode(); |
1969 } | 1959 } |
1970 | 1960 |
1971 | 1961 |
1972 #undef __ | 1962 #undef __ |
1973 | 1963 |
1974 } } // namespace v8::internal | 1964 } } // namespace v8::internal |
OLD | NEW |