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

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

Issue 2087009: Custom call IC-s for String.prototype.{charAt,charCodeAt}. (Closed)
Patch Set: ARM port. Created 10 years, 7 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
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 1336 matching lines...) Expand 10 before | Expand all | Expand 10 after
1347 1347
1348 __ bind(&miss); 1348 __ bind(&miss);
1349 Handle<Code> ic = ComputeCallMiss(arguments().immediate()); 1349 Handle<Code> ic = ComputeCallMiss(arguments().immediate());
1350 __ jmp(ic, RelocInfo::CODE_TARGET); 1350 __ jmp(ic, RelocInfo::CODE_TARGET);
1351 1351
1352 // Return the generated code. 1352 // Return the generated code.
1353 return GetCode(function); 1353 return GetCode(function);
1354 } 1354 }
1355 1355
1356 1356
1357 Object* CallStubCompiler::CompileStringCharCodeAtCall(Object* object,
1358 JSObject* holder,
1359 JSFunction* function,
1360 String* name,
1361 CheckType check) {
1362 // ----------- S t a t e -------------
1363 // -- ecx : function name
1364 // -- esp[0] : return address
1365 // -- esp[(argc - n) * 4] : arg[n] (zero-based)
1366 // -- ...
1367 // -- esp[(argc + 1) * 4] : receiver
1368 // -----------------------------------
1369
1370 const int argc = arguments().immediate();
1371
1372 Label miss;
1373 Label index_out_of_range;
1374
1375 // Check that the maps starting from the prototype haven't changed.
1376 GenerateLoadGlobalFunctionPrototype(masm(),
1377 Context::STRING_FUNCTION_INDEX,
1378 eax);
1379 CheckPrototypes(JSObject::cast(object->GetPrototype()), eax, holder,
1380 ebx, edx, name, &miss);
1381
1382 Register receiver = ebx;
1383 Register index = ecx;
1384 Register scratch = edx;
1385 Register result = eax;
1386 __ mov(receiver, Operand(esp, (argc + 1) * kPointerSize));
1387 if (argc > 0) {
1388 __ mov(index, Operand(esp, (argc - 0) * kPointerSize));
1389 } else {
1390 __ Set(index, Immediate(Factory::undefined_value()));
1391 }
1392
1393 StringCharCodeAtGenerator char_code_at_generator(receiver,
1394 index,
1395 scratch,
1396 result,
1397 &miss, // When not a string.
1398 &miss, // When not a number.
1399 &index_out_of_range,
1400 STRING_ANY_NUMBER_INDEX);
1401 char_code_at_generator.GenerateFast(masm());
1402 __ ret((argc + 1) * kPointerSize);
1403
1404 ICRuntimeCallHelper call_helper;
1405 char_code_at_generator.GenerateSlow(masm(), call_helper);
1406
1407 __ bind(&index_out_of_range);
1408 __ Set(eax, Immediate(Factory::nan_value()));
1409 __ ret((argc + 1) * kPointerSize);
1410
1411 __ bind(&miss);
1412 // Restore function name in ecx.
1413 __ Set(ecx, Immediate(Handle<String>(name)));
1414
1415 Handle<Code> ic = ComputeCallMiss(argc);
1416 __ jmp(ic, RelocInfo::CODE_TARGET);
1417
1418 // Return the generated code.
1419 return GetCode(function);
1420 }
1421
1422
1423 Object* CallStubCompiler::CompileStringCharAtCall(Object* object,
1424 JSObject* holder,
1425 JSFunction* function,
1426 String* name,
1427 CheckType check) {
1428 // ----------- S t a t e -------------
1429 // -- ecx : function name
1430 // -- esp[0] : return address
1431 // -- esp[(argc - n) * 4] : arg[n] (zero-based)
1432 // -- ...
1433 // -- esp[(argc + 1) * 4] : receiver
1434 // -----------------------------------
1435
1436 const int argc = arguments().immediate();
1437
1438 Label miss;
1439 Label index_out_of_range;
1440
1441 // Check that the maps starting from the prototype haven't changed.
1442 GenerateLoadGlobalFunctionPrototype(masm(),
1443 Context::STRING_FUNCTION_INDEX,
1444 eax);
1445 CheckPrototypes(JSObject::cast(object->GetPrototype()), eax, holder,
1446 ebx, edx, name, &miss);
1447
1448 Register receiver = eax;
1449 Register index = ecx;
1450 Register scratch1 = ebx;
1451 Register scratch2 = edx;
1452 Register result = eax;
1453 __ mov(receiver, Operand(esp, (argc + 1) * kPointerSize));
1454 if (argc > 0) {
1455 __ mov(index, Operand(esp, (argc - 0) * kPointerSize));
1456 } else {
1457 __ Set(index, Immediate(Factory::undefined_value()));
1458 }
1459
1460 StringCharAtGenerator char_at_generator(receiver,
1461 index,
1462 scratch1,
1463 scratch2,
1464 result,
1465 &miss, // When not a string.
1466 &miss, // When not a number.
1467 &index_out_of_range,
1468 STRING_ANY_NUMBER_INDEX);
1469 char_at_generator.GenerateFast(masm());
1470 __ ret((argc + 1) * kPointerSize);
1471
1472 ICRuntimeCallHelper call_helper;
1473 char_at_generator.GenerateSlow(masm(), call_helper);
1474
1475 __ bind(&index_out_of_range);
1476 __ Set(eax, Immediate(Factory::empty_string()));
1477 __ ret((argc + 1) * kPointerSize);
1478
1479 __ bind(&miss);
1480 // Restore function name in ecx.
1481 __ Set(ecx, Immediate(Handle<String>(name)));
1482
1483 Handle<Code> ic = ComputeCallMiss(argc);
1484 __ jmp(ic, RelocInfo::CODE_TARGET);
1485
1486 // Return the generated code.
1487 return GetCode(function);
1488 }
1489
1490
1357 Object* CallStubCompiler::CompileCallConstant(Object* object, 1491 Object* CallStubCompiler::CompileCallConstant(Object* object,
1358 JSObject* holder, 1492 JSObject* holder,
1359 JSFunction* function, 1493 JSFunction* function,
1360 String* name, 1494 String* name,
1361 CheckType check) { 1495 CheckType check) {
1362 // ----------- S t a t e ------------- 1496 // ----------- S t a t e -------------
1363 // -- ecx : name 1497 // -- ecx : name
1364 // -- esp[0] : return address 1498 // -- esp[0] : return address
1365 // -- esp[(argc - n) * 4] : arg[n] (zero-based) 1499 // -- esp[(argc - n) * 4] : arg[n] (zero-based)
1366 // -- ... 1500 // -- ...
(...skipping 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after
2382 // Return the generated code. 2516 // Return the generated code.
2383 return GetCode(); 2517 return GetCode();
2384 } 2518 }
2385 2519
2386 2520
2387 #undef __ 2521 #undef __
2388 2522
2389 } } // namespace v8::internal 2523 } } // namespace v8::internal
2390 2524
2391 #endif // V8_TARGET_ARCH_IA32 2525 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« src/codegen.h ('K') | « src/ia32/ic-ia32.cc ('k') | src/ia32/virtual-frame-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698