OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 1273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1284 // Return the generated code. | 1284 // Return the generated code. |
1285 return GetCode(function); | 1285 return GetCode(function); |
1286 } | 1286 } |
1287 | 1287 |
1288 | 1288 |
1289 Object* CallStubCompiler::CompileStringCharAtCall(Object* object, | 1289 Object* CallStubCompiler::CompileStringCharAtCall(Object* object, |
1290 JSObject* holder, | 1290 JSObject* holder, |
1291 JSFunction* function, | 1291 JSFunction* function, |
1292 String* name, | 1292 String* name, |
1293 CheckType check) { | 1293 CheckType check) { |
1294 // TODO(722): implement this. | 1294 // ----------- S t a t e ------------- |
1295 return Heap::undefined_value(); | 1295 // -- rcx : function name |
| 1296 // -- rsp[0] : return address |
| 1297 // -- rsp[(argc - n) * 8] : arg[n] (zero-based) |
| 1298 // -- ... |
| 1299 // -- rsp[(argc + 1) * 8] : receiver |
| 1300 // ----------------------------------- |
| 1301 |
| 1302 // If object is not a string, bail out to regular call. |
| 1303 if (!object->IsString()) return Heap::undefined_value(); |
| 1304 |
| 1305 const int argc = arguments().immediate(); |
| 1306 |
| 1307 Label miss; |
| 1308 Label index_out_of_range; |
| 1309 |
| 1310 GenerateNameCheck(name, &miss); |
| 1311 |
| 1312 // Check that the maps starting from the prototype haven't changed. |
| 1313 GenerateDirectLoadGlobalFunctionPrototype(masm(), |
| 1314 Context::STRING_FUNCTION_INDEX, |
| 1315 rax); |
| 1316 ASSERT(object != holder); |
| 1317 CheckPrototypes(JSObject::cast(object->GetPrototype()), rax, holder, |
| 1318 rbx, rdx, rdi, name, &miss); |
| 1319 |
| 1320 Register receiver = rax; |
| 1321 Register index = rdi; |
| 1322 Register scratch1 = rbx; |
| 1323 Register scratch2 = rdx; |
| 1324 Register result = rax; |
| 1325 __ movq(receiver, Operand(rsp, (argc + 1) * kPointerSize)); |
| 1326 if (argc > 0) { |
| 1327 __ movq(index, Operand(rsp, (argc - 0) * kPointerSize)); |
| 1328 } else { |
| 1329 __ LoadRoot(index, Heap::kUndefinedValueRootIndex); |
| 1330 } |
| 1331 |
| 1332 StringCharAtGenerator char_at_generator(receiver, |
| 1333 index, |
| 1334 scratch1, |
| 1335 scratch2, |
| 1336 result, |
| 1337 &miss, // When not a string. |
| 1338 &miss, // When not a number. |
| 1339 &index_out_of_range, |
| 1340 STRING_INDEX_IS_NUMBER); |
| 1341 char_at_generator.GenerateFast(masm()); |
| 1342 __ ret((argc + 1) * kPointerSize); |
| 1343 |
| 1344 ICRuntimeCallHelper call_helper; |
| 1345 char_at_generator.GenerateSlow(masm(), call_helper); |
| 1346 |
| 1347 __ bind(&index_out_of_range); |
| 1348 __ LoadRoot(rax, Heap::kEmptyStringRootIndex); |
| 1349 __ ret((argc + 1) * kPointerSize); |
| 1350 |
| 1351 __ bind(&miss); |
| 1352 Object* obj = GenerateMissBranch(); |
| 1353 if (obj->IsFailure()) return obj; |
| 1354 |
| 1355 // Return the generated code. |
| 1356 return GetCode(function); |
1296 } | 1357 } |
1297 | 1358 |
1298 | 1359 |
1299 Object* CallStubCompiler::CompileStringCharCodeAtCall(Object* object, | 1360 Object* CallStubCompiler::CompileStringCharCodeAtCall(Object* object, |
1300 JSObject* holder, | 1361 JSObject* holder, |
1301 JSFunction* function, | 1362 JSFunction* function, |
1302 String* name, | 1363 String* name, |
1303 CheckType check) { | 1364 CheckType check) { |
1304 // TODO(722): implement this. | 1365 // ----------- S t a t e ------------- |
1305 return Heap::undefined_value(); | 1366 // -- rcx : function name |
| 1367 // -- rsp[0] : return address |
| 1368 // -- rsp[(argc - n) * 8] : arg[n] (zero-based) |
| 1369 // -- ... |
| 1370 // -- rsp[(argc + 1) * 8] : receiver |
| 1371 // ----------------------------------- |
| 1372 |
| 1373 // If object is not a string, bail out to regular call. |
| 1374 if (!object->IsString()) return Heap::undefined_value(); |
| 1375 |
| 1376 const int argc = arguments().immediate(); |
| 1377 |
| 1378 Label miss; |
| 1379 Label index_out_of_range; |
| 1380 GenerateNameCheck(name, &miss); |
| 1381 |
| 1382 // Check that the maps starting from the prototype haven't changed. |
| 1383 GenerateDirectLoadGlobalFunctionPrototype(masm(), |
| 1384 Context::STRING_FUNCTION_INDEX, |
| 1385 rax); |
| 1386 ASSERT(object != holder); |
| 1387 CheckPrototypes(JSObject::cast(object->GetPrototype()), rax, holder, |
| 1388 rbx, rdx, rdi, name, &miss); |
| 1389 |
| 1390 Register receiver = rbx; |
| 1391 Register index = rdi; |
| 1392 Register scratch = rdx; |
| 1393 Register result = rax; |
| 1394 __ movq(receiver, Operand(rsp, (argc + 1) * kPointerSize)); |
| 1395 if (argc > 0) { |
| 1396 __ movq(index, Operand(rsp, (argc - 0) * kPointerSize)); |
| 1397 } else { |
| 1398 __ LoadRoot(index, Heap::kUndefinedValueRootIndex); |
| 1399 } |
| 1400 |
| 1401 StringCharCodeAtGenerator char_code_at_generator(receiver, |
| 1402 index, |
| 1403 scratch, |
| 1404 result, |
| 1405 &miss, // When not a string. |
| 1406 &miss, // When not a number. |
| 1407 &index_out_of_range, |
| 1408 STRING_INDEX_IS_NUMBER); |
| 1409 char_code_at_generator.GenerateFast(masm()); |
| 1410 __ ret((argc + 1) * kPointerSize); |
| 1411 |
| 1412 ICRuntimeCallHelper call_helper; |
| 1413 char_code_at_generator.GenerateSlow(masm(), call_helper); |
| 1414 |
| 1415 __ bind(&index_out_of_range); |
| 1416 __ LoadRoot(rax, Heap::kNanValueRootIndex); |
| 1417 __ ret((argc + 1) * kPointerSize); |
| 1418 |
| 1419 __ bind(&miss); |
| 1420 Object* obj = GenerateMissBranch(); |
| 1421 if (obj->IsFailure()) return obj; |
| 1422 |
| 1423 // Return the generated code. |
| 1424 return GetCode(function); |
1306 } | 1425 } |
1307 | 1426 |
1308 | 1427 |
1309 | |
1310 Object* CallStubCompiler::CompileCallInterceptor(JSObject* object, | 1428 Object* CallStubCompiler::CompileCallInterceptor(JSObject* object, |
1311 JSObject* holder, | 1429 JSObject* holder, |
1312 String* name) { | 1430 String* name) { |
1313 // ----------- S t a t e ------------- | 1431 // ----------- S t a t e ------------- |
1314 // rcx : function name | 1432 // rcx : function name |
1315 // rsp[0] : return address | 1433 // rsp[0] : return address |
1316 // rsp[8] : argument argc | 1434 // rsp[8] : argument argc |
1317 // rsp[16] : argument argc - 1 | 1435 // rsp[16] : argument argc - 1 |
1318 // ... | 1436 // ... |
1319 // rsp[argc * 8] : argument 1 | 1437 // rsp[argc * 8] : argument 1 |
(...skipping 1274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2594 // Return the generated code. | 2712 // Return the generated code. |
2595 return GetCode(); | 2713 return GetCode(); |
2596 } | 2714 } |
2597 | 2715 |
2598 | 2716 |
2599 #undef __ | 2717 #undef __ |
2600 | 2718 |
2601 } } // namespace v8::internal | 2719 } } // namespace v8::internal |
2602 | 2720 |
2603 #endif // V8_TARGET_ARCH_X64 | 2721 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |