| 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 908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 919 __ cmpq(FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset), rax); | 919 __ cmpq(FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset), rax); |
| 920 __ j(not_equal, miss); | 920 __ j(not_equal, miss); |
| 921 } else { | 921 } else { |
| 922 __ Cmp(rdi, Handle<JSFunction>(function)); | 922 __ Cmp(rdi, Handle<JSFunction>(function)); |
| 923 __ j(not_equal, miss); | 923 __ j(not_equal, miss); |
| 924 } | 924 } |
| 925 } | 925 } |
| 926 | 926 |
| 927 | 927 |
| 928 MaybeObject* CallStubCompiler::GenerateMissBranch() { | 928 MaybeObject* CallStubCompiler::GenerateMissBranch() { |
| 929 MaybeObject* maybe_obj = Isolate::Current()->stub_cache()-> |
| 930 ComputeCallMiss(arguments().immediate(), kind_); |
| 929 Object* obj; | 931 Object* obj; |
| 930 { MaybeObject* maybe_obj = Isolate::Current()->stub_cache()-> | 932 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
| 931 ComputeCallMiss(arguments().immediate(), kind_); | |
| 932 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | |
| 933 } | |
| 934 __ Jump(Handle<Code>(Code::cast(obj)), RelocInfo::CODE_TARGET); | 933 __ Jump(Handle<Code>(Code::cast(obj)), RelocInfo::CODE_TARGET); |
| 935 return obj; | 934 return obj; |
| 936 } | 935 } |
| 937 | 936 |
| 938 | 937 |
| 939 MaybeObject* CallStubCompiler::CompileCallConstant( | 938 MaybeObject* CallStubCompiler::CompileCallConstant(Object* object, |
| 940 Object* object, | 939 JSObject* holder, |
| 941 JSObject* holder, | 940 JSFunction* function, |
| 942 JSFunction* function, | 941 String* name, |
| 943 String* name, | 942 CheckType check) { |
| 944 StubCompiler::CheckType check) { | |
| 945 // ----------- S t a t e ------------- | 943 // ----------- S t a t e ------------- |
| 946 // rcx : function name | 944 // rcx : function name |
| 947 // rsp[0] : return address | 945 // rsp[0] : return address |
| 948 // rsp[8] : argument argc | 946 // rsp[8] : argument argc |
| 949 // rsp[16] : argument argc - 1 | 947 // rsp[16] : argument argc - 1 |
| 950 // ... | 948 // ... |
| 951 // rsp[argc * 8] : argument 1 | 949 // rsp[argc * 8] : argument 1 |
| 952 // rsp[(argc + 1) * 8] : argument 0 = receiver | 950 // rsp[(argc + 1) * 8] : argument 0 = receiver |
| 953 // ----------------------------------- | 951 // ----------------------------------- |
| 954 | 952 |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1463 scratch1, | 1461 scratch1, |
| 1464 scratch2, | 1462 scratch2, |
| 1465 result, | 1463 result, |
| 1466 &miss, // When not a string. | 1464 &miss, // When not a string. |
| 1467 &miss, // When not a number. | 1465 &miss, // When not a number. |
| 1468 &index_out_of_range, | 1466 &index_out_of_range, |
| 1469 STRING_INDEX_IS_NUMBER); | 1467 STRING_INDEX_IS_NUMBER); |
| 1470 char_at_generator.GenerateFast(masm()); | 1468 char_at_generator.GenerateFast(masm()); |
| 1471 __ ret((argc + 1) * kPointerSize); | 1469 __ ret((argc + 1) * kPointerSize); |
| 1472 | 1470 |
| 1473 ICRuntimeCallHelper call_helper; | 1471 StubRuntimeCallHelper call_helper; |
| 1474 char_at_generator.GenerateSlow(masm(), call_helper); | 1472 char_at_generator.GenerateSlow(masm(), call_helper); |
| 1475 | 1473 |
| 1476 __ bind(&index_out_of_range); | 1474 __ bind(&index_out_of_range); |
| 1477 __ LoadRoot(rax, Heap::kEmptyStringRootIndex); | 1475 __ LoadRoot(rax, Heap::kEmptyStringRootIndex); |
| 1478 __ ret((argc + 1) * kPointerSize); | 1476 __ ret((argc + 1) * kPointerSize); |
| 1479 | 1477 |
| 1480 __ bind(&miss); | 1478 __ bind(&miss); |
| 1481 Object* obj; | 1479 Object* obj; |
| 1482 { MaybeObject* maybe_obj = GenerateMissBranch(); | 1480 { MaybeObject* maybe_obj = GenerateMissBranch(); |
| 1483 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 1481 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1535 index, | 1533 index, |
| 1536 scratch, | 1534 scratch, |
| 1537 result, | 1535 result, |
| 1538 &miss, // When not a string. | 1536 &miss, // When not a string. |
| 1539 &miss, // When not a number. | 1537 &miss, // When not a number. |
| 1540 &index_out_of_range, | 1538 &index_out_of_range, |
| 1541 STRING_INDEX_IS_NUMBER); | 1539 STRING_INDEX_IS_NUMBER); |
| 1542 char_code_at_generator.GenerateFast(masm()); | 1540 char_code_at_generator.GenerateFast(masm()); |
| 1543 __ ret((argc + 1) * kPointerSize); | 1541 __ ret((argc + 1) * kPointerSize); |
| 1544 | 1542 |
| 1545 ICRuntimeCallHelper call_helper; | 1543 StubRuntimeCallHelper call_helper; |
| 1546 char_code_at_generator.GenerateSlow(masm(), call_helper); | 1544 char_code_at_generator.GenerateSlow(masm(), call_helper); |
| 1547 | 1545 |
| 1548 __ bind(&index_out_of_range); | 1546 __ bind(&index_out_of_range); |
| 1549 __ LoadRoot(rax, Heap::kNanValueRootIndex); | 1547 __ LoadRoot(rax, Heap::kNanValueRootIndex); |
| 1550 __ ret((argc + 1) * kPointerSize); | 1548 __ ret((argc + 1) * kPointerSize); |
| 1551 | 1549 |
| 1552 __ bind(&miss); | 1550 __ bind(&miss); |
| 1553 Object* obj; | 1551 Object* obj; |
| 1554 { MaybeObject* maybe_obj = GenerateMissBranch(); | 1552 { MaybeObject* maybe_obj = GenerateMissBranch(); |
| 1555 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 1553 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1604 Label slow; | 1602 Label slow; |
| 1605 __ JumpIfNotSmi(code, &slow); | 1603 __ JumpIfNotSmi(code, &slow); |
| 1606 | 1604 |
| 1607 // Convert the smi code to uint16. | 1605 // Convert the smi code to uint16. |
| 1608 __ SmiAndConstant(code, code, Smi::FromInt(0xffff)); | 1606 __ SmiAndConstant(code, code, Smi::FromInt(0xffff)); |
| 1609 | 1607 |
| 1610 StringCharFromCodeGenerator char_from_code_generator(code, rax); | 1608 StringCharFromCodeGenerator char_from_code_generator(code, rax); |
| 1611 char_from_code_generator.GenerateFast(masm()); | 1609 char_from_code_generator.GenerateFast(masm()); |
| 1612 __ ret(2 * kPointerSize); | 1610 __ ret(2 * kPointerSize); |
| 1613 | 1611 |
| 1614 ICRuntimeCallHelper call_helper; | 1612 StubRuntimeCallHelper call_helper; |
| 1615 char_from_code_generator.GenerateSlow(masm(), call_helper); | 1613 char_from_code_generator.GenerateSlow(masm(), call_helper); |
| 1616 | 1614 |
| 1617 // Tail call the full function. We do not have to patch the receiver | 1615 // Tail call the full function. We do not have to patch the receiver |
| 1618 // because the function makes no use of it. | 1616 // because the function makes no use of it. |
| 1619 __ bind(&slow); | 1617 __ bind(&slow); |
| 1620 __ InvokeFunction(function, arguments(), JUMP_FUNCTION); | 1618 __ InvokeFunction(function, arguments(), JUMP_FUNCTION); |
| 1621 | 1619 |
| 1622 __ bind(&miss); | 1620 __ bind(&miss); |
| 1623 // rcx: function name. | 1621 // rcx: function name. |
| 1624 Object* obj; | 1622 Object* obj; |
| (...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2245 GenerateLoadStringLength(masm(), rdx, rcx, rbx, &miss); | 2243 GenerateLoadStringLength(masm(), rdx, rcx, rbx, &miss); |
| 2246 __ bind(&miss); | 2244 __ bind(&miss); |
| 2247 __ DecrementCounter(COUNTERS->keyed_load_string_length(), 1); | 2245 __ DecrementCounter(COUNTERS->keyed_load_string_length(), 1); |
| 2248 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); | 2246 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); |
| 2249 | 2247 |
| 2250 // Return the generated code. | 2248 // Return the generated code. |
| 2251 return GetCode(CALLBACKS, name); | 2249 return GetCode(CALLBACKS, name); |
| 2252 } | 2250 } |
| 2253 | 2251 |
| 2254 | 2252 |
| 2253 MaybeObject* KeyedLoadStubCompiler::CompileLoadSpecialized(JSObject* receiver) { |
| 2254 // ----------- S t a t e ------------- |
| 2255 // -- rax : key |
| 2256 // -- rdx : receiver |
| 2257 // -- esp[0] : return address |
| 2258 // ----------------------------------- |
| 2259 Label miss; |
| 2260 |
| 2261 // Check that the receiver isn't a smi. |
| 2262 __ JumpIfSmi(rdx, &miss); |
| 2263 |
| 2264 // Check that the map matches. |
| 2265 __ Cmp(FieldOperand(rdx, HeapObject::kMapOffset), |
| 2266 Handle<Map>(receiver->map())); |
| 2267 __ j(not_equal, &miss); |
| 2268 |
| 2269 // Check that the key is a smi. |
| 2270 __ JumpIfNotSmi(rax, &miss); |
| 2271 |
| 2272 // Get the elements array. |
| 2273 __ movq(rcx, FieldOperand(rdx, JSObject::kElementsOffset)); |
| 2274 __ AssertFastElements(rcx); |
| 2275 |
| 2276 // Check that the key is within bounds. |
| 2277 __ SmiCompare(rax, FieldOperand(rcx, FixedArray::kLengthOffset)); |
| 2278 __ j(above_equal, &miss); |
| 2279 |
| 2280 // Load the result and make sure it's not the hole. |
| 2281 SmiIndex index = masm()->SmiToIndex(rbx, rax, kPointerSizeLog2); |
| 2282 __ movq(rbx, FieldOperand(rcx, |
| 2283 index.reg, |
| 2284 index.scale, |
| 2285 FixedArray::kHeaderSize)); |
| 2286 __ CompareRoot(rbx, Heap::kTheHoleValueRootIndex); |
| 2287 __ j(equal, &miss); |
| 2288 __ movq(rax, rbx); |
| 2289 __ ret(0); |
| 2290 |
| 2291 __ bind(&miss); |
| 2292 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); |
| 2293 |
| 2294 // Return the generated code. |
| 2295 return GetCode(NORMAL, NULL); |
| 2296 } |
| 2297 |
| 2298 |
| 2255 MaybeObject* StoreStubCompiler::CompileStoreCallback(JSObject* object, | 2299 MaybeObject* StoreStubCompiler::CompileStoreCallback(JSObject* object, |
| 2256 AccessorInfo* callback, | 2300 AccessorInfo* callback, |
| 2257 String* name) { | 2301 String* name) { |
| 2258 // ----------- S t a t e ------------- | 2302 // ----------- S t a t e ------------- |
| 2259 // -- rax : value | 2303 // -- rax : value |
| 2260 // -- rcx : name | 2304 // -- rcx : name |
| 2261 // -- rdx : receiver | 2305 // -- rdx : receiver |
| 2262 // -- rsp[0] : return address | 2306 // -- rsp[0] : return address |
| 2263 // ----------------------------------- | 2307 // ----------------------------------- |
| 2264 Label miss; | 2308 Label miss; |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2478 __ DecrementCounter(COUNTERS->keyed_store_field(), 1); | 2522 __ DecrementCounter(COUNTERS->keyed_store_field(), 1); |
| 2479 Handle<Code> ic(Isolate::Current()->builtins()->builtin( | 2523 Handle<Code> ic(Isolate::Current()->builtins()->builtin( |
| 2480 Builtins::KeyedStoreIC_Miss)); | 2524 Builtins::KeyedStoreIC_Miss)); |
| 2481 __ Jump(ic, RelocInfo::CODE_TARGET); | 2525 __ Jump(ic, RelocInfo::CODE_TARGET); |
| 2482 | 2526 |
| 2483 // Return the generated code. | 2527 // Return the generated code. |
| 2484 return GetCode(transition == NULL ? FIELD : MAP_TRANSITION, name); | 2528 return GetCode(transition == NULL ? FIELD : MAP_TRANSITION, name); |
| 2485 } | 2529 } |
| 2486 | 2530 |
| 2487 | 2531 |
| 2532 MaybeObject* KeyedStoreStubCompiler::CompileStoreSpecialized( |
| 2533 JSObject* receiver) { |
| 2534 // ----------- S t a t e ------------- |
| 2535 // -- rax : value |
| 2536 // -- rcx : key |
| 2537 // -- rdx : receiver |
| 2538 // -- rsp[0] : return address |
| 2539 // ----------------------------------- |
| 2540 Label miss; |
| 2541 |
| 2542 // Check that the receiver isn't a smi. |
| 2543 __ JumpIfSmi(rdx, &miss); |
| 2544 |
| 2545 // Check that the map matches. |
| 2546 __ Cmp(FieldOperand(rdx, HeapObject::kMapOffset), |
| 2547 Handle<Map>(receiver->map())); |
| 2548 __ j(not_equal, &miss); |
| 2549 |
| 2550 // Check that the key is a smi. |
| 2551 __ JumpIfNotSmi(rcx, &miss); |
| 2552 |
| 2553 // Get the elements array and make sure it is a fast element array, not 'cow'. |
| 2554 __ movq(rdi, FieldOperand(rdx, JSObject::kElementsOffset)); |
| 2555 __ Cmp(FieldOperand(rdi, HeapObject::kMapOffset), |
| 2556 FACTORY->fixed_array_map()); |
| 2557 __ j(not_equal, &miss); |
| 2558 |
| 2559 // Check that the key is within bounds. |
| 2560 if (receiver->IsJSArray()) { |
| 2561 __ SmiCompare(rcx, FieldOperand(rdx, JSArray::kLengthOffset)); |
| 2562 __ j(above_equal, &miss); |
| 2563 } else { |
| 2564 __ SmiCompare(rcx, FieldOperand(rdi, FixedArray::kLengthOffset)); |
| 2565 __ j(above_equal, &miss); |
| 2566 } |
| 2567 |
| 2568 // Do the store and update the write barrier. Make sure to preserve |
| 2569 // the value in register eax. |
| 2570 __ movq(rdx, rax); |
| 2571 __ SmiToInteger32(rcx, rcx); |
| 2572 __ movq(FieldOperand(rdi, rcx, times_pointer_size, FixedArray::kHeaderSize), |
| 2573 rax); |
| 2574 __ RecordWrite(rdi, 0, rdx, rcx); |
| 2575 |
| 2576 // Done. |
| 2577 __ ret(0); |
| 2578 |
| 2579 // Handle store cache miss. |
| 2580 __ bind(&miss); |
| 2581 Handle<Code> ic( |
| 2582 Isolate::Current()->builtins()->builtin(Builtins::KeyedStoreIC_Miss)); |
| 2583 __ jmp(ic, RelocInfo::CODE_TARGET); |
| 2584 |
| 2585 // Return the generated code. |
| 2586 return GetCode(NORMAL, NULL); |
| 2587 } |
| 2588 |
| 2589 |
| 2488 void StubCompiler::GenerateLoadInterceptor(JSObject* object, | 2590 void StubCompiler::GenerateLoadInterceptor(JSObject* object, |
| 2489 JSObject* interceptor_holder, | 2591 JSObject* interceptor_holder, |
| 2490 LookupResult* lookup, | 2592 LookupResult* lookup, |
| 2491 Register receiver, | 2593 Register receiver, |
| 2492 Register name_reg, | 2594 Register name_reg, |
| 2493 Register scratch1, | 2595 Register scratch1, |
| 2494 Register scratch2, | 2596 Register scratch2, |
| 2495 Register scratch3, | 2597 Register scratch3, |
| 2496 String* name, | 2598 String* name, |
| 2497 Label* miss) { | 2599 Label* miss) { |
| (...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3026 // Return the generated code. | 3128 // Return the generated code. |
| 3027 return GetCode(); | 3129 return GetCode(); |
| 3028 } | 3130 } |
| 3029 | 3131 |
| 3030 | 3132 |
| 3031 #undef __ | 3133 #undef __ |
| 3032 | 3134 |
| 3033 } } // namespace v8::internal | 3135 } } // namespace v8::internal |
| 3034 | 3136 |
| 3035 #endif // V8_TARGET_ARCH_X64 | 3137 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |