| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #if V8_TARGET_ARCH_X87 | 5 #if V8_TARGET_ARCH_X87 |
| 6 | 6 |
| 7 #include "src/ic/handler-compiler.h" | 7 #include "src/ic/handler-compiler.h" |
| 8 | 8 |
| 9 #include "src/api-arguments.h" | 9 #include "src/api-arguments.h" |
| 10 #include "src/field-type.h" | 10 #include "src/field-type.h" |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 break; | 192 break; |
| 193 case CallOptimization::kHolderNotFound: | 193 case CallOptimization::kHolderNotFound: |
| 194 UNREACHABLE(); | 194 UNREACHABLE(); |
| 195 break; | 195 break; |
| 196 } | 196 } |
| 197 | 197 |
| 198 Isolate* isolate = masm->isolate(); | 198 Isolate* isolate = masm->isolate(); |
| 199 Handle<CallHandlerInfo> api_call_info = optimization.api_call_info(); | 199 Handle<CallHandlerInfo> api_call_info = optimization.api_call_info(); |
| 200 bool call_data_undefined = false; | 200 bool call_data_undefined = false; |
| 201 // Put call data in place. | 201 // Put call data in place. |
| 202 if (api_call_info->data()->IsUndefined()) { | 202 if (api_call_info->data()->IsUndefined(isolate)) { |
| 203 call_data_undefined = true; | 203 call_data_undefined = true; |
| 204 __ mov(data, Immediate(isolate->factory()->undefined_value())); | 204 __ mov(data, Immediate(isolate->factory()->undefined_value())); |
| 205 } else { | 205 } else { |
| 206 if (optimization.is_constant_call()) { | 206 if (optimization.is_constant_call()) { |
| 207 __ mov(data, FieldOperand(callee, JSFunction::kSharedFunctionInfoOffset)); | 207 __ mov(data, FieldOperand(callee, JSFunction::kSharedFunctionInfoOffset)); |
| 208 __ mov(data, FieldOperand(data, SharedFunctionInfo::kFunctionDataOffset)); | 208 __ mov(data, FieldOperand(data, SharedFunctionInfo::kFunctionDataOffset)); |
| 209 __ mov(data, FieldOperand(data, FunctionTemplateInfo::kCallCodeOffset)); | 209 __ mov(data, FieldOperand(data, FunctionTemplateInfo::kCallCodeOffset)); |
| 210 } else { | 210 } else { |
| 211 __ mov(data, FieldOperand(callee, FunctionTemplateInfo::kCallCodeOffset)); | 211 __ mov(data, FieldOperand(callee, FunctionTemplateInfo::kCallCodeOffset)); |
| 212 } | 212 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 230 } | 230 } |
| 231 | 231 |
| 232 | 232 |
| 233 // Generate code to check that a global property cell is empty. Create | 233 // Generate code to check that a global property cell is empty. Create |
| 234 // the property cell at compilation time if no cell exists for the | 234 // the property cell at compilation time if no cell exists for the |
| 235 // property. | 235 // property. |
| 236 void PropertyHandlerCompiler::GenerateCheckPropertyCell( | 236 void PropertyHandlerCompiler::GenerateCheckPropertyCell( |
| 237 MacroAssembler* masm, Handle<JSGlobalObject> global, Handle<Name> name, | 237 MacroAssembler* masm, Handle<JSGlobalObject> global, Handle<Name> name, |
| 238 Register scratch, Label* miss) { | 238 Register scratch, Label* miss) { |
| 239 Handle<PropertyCell> cell = JSGlobalObject::EnsurePropertyCell(global, name); | 239 Handle<PropertyCell> cell = JSGlobalObject::EnsurePropertyCell(global, name); |
| 240 DCHECK(cell->value()->IsTheHole()); | 240 Isolate* isolate = masm->isolate(); |
| 241 Factory* factory = masm->isolate()->factory(); | 241 DCHECK(cell->value()->IsTheHole(isolate)); |
| 242 Handle<WeakCell> weak_cell = factory->NewWeakCell(cell); | 242 Handle<WeakCell> weak_cell = isolate->factory()->NewWeakCell(cell); |
| 243 __ LoadWeakValue(scratch, weak_cell, miss); | 243 __ LoadWeakValue(scratch, weak_cell, miss); |
| 244 __ cmp(FieldOperand(scratch, PropertyCell::kValueOffset), | 244 __ cmp(FieldOperand(scratch, PropertyCell::kValueOffset), |
| 245 Immediate(factory->the_hole_value())); | 245 Immediate(isolate->factory()->the_hole_value())); |
| 246 __ j(not_equal, miss); | 246 __ j(not_equal, miss); |
| 247 } | 247 } |
| 248 | 248 |
| 249 | 249 |
| 250 void NamedStoreHandlerCompiler::GenerateStoreViaSetter( | 250 void NamedStoreHandlerCompiler::GenerateStoreViaSetter( |
| 251 MacroAssembler* masm, Handle<Map> map, Register receiver, Register holder, | 251 MacroAssembler* masm, Handle<Map> map, Register receiver, Register holder, |
| 252 int accessor_index, int expected_arguments, Register scratch) { | 252 int accessor_index, int expected_arguments, Register scratch) { |
| 253 // ----------- S t a t e ------------- | 253 // ----------- S t a t e ------------- |
| 254 // -- esp[0] : return address | 254 // -- esp[0] : return address |
| 255 // ----------------------------------- | 255 // ----------------------------------- |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 void NamedLoadHandlerCompiler::GenerateLoadConstant(Handle<Object> value) { | 565 void NamedLoadHandlerCompiler::GenerateLoadConstant(Handle<Object> value) { |
| 566 // Return the constant value. | 566 // Return the constant value. |
| 567 __ LoadObject(eax, value); | 567 __ LoadObject(eax, value); |
| 568 __ ret(0); | 568 __ ret(0); |
| 569 } | 569 } |
| 570 | 570 |
| 571 | 571 |
| 572 void NamedLoadHandlerCompiler::GenerateLoadInterceptorWithFollowup( | 572 void NamedLoadHandlerCompiler::GenerateLoadInterceptorWithFollowup( |
| 573 LookupIterator* it, Register holder_reg) { | 573 LookupIterator* it, Register holder_reg) { |
| 574 DCHECK(holder()->HasNamedInterceptor()); | 574 DCHECK(holder()->HasNamedInterceptor()); |
| 575 DCHECK(!holder()->GetNamedInterceptor()->getter()->IsUndefined()); | 575 DCHECK(!holder()->GetNamedInterceptor()->getter()->IsUndefined(isolate())); |
| 576 | 576 |
| 577 // Compile the interceptor call, followed by inline code to load the | 577 // Compile the interceptor call, followed by inline code to load the |
| 578 // property from further up the prototype chain if the call fails. | 578 // property from further up the prototype chain if the call fails. |
| 579 // Check that the maps haven't changed. | 579 // Check that the maps haven't changed. |
| 580 DCHECK(holder_reg.is(receiver()) || holder_reg.is(scratch1())); | 580 DCHECK(holder_reg.is(receiver()) || holder_reg.is(scratch1())); |
| 581 | 581 |
| 582 // Preserve the receiver register explicitly whenever it is different from the | 582 // Preserve the receiver register explicitly whenever it is different from the |
| 583 // holder and it is needed should the interceptor return without any result. | 583 // holder and it is needed should the interceptor return without any result. |
| 584 // The ACCESSOR case needs the receiver to be passed into C++ code, the FIELD | 584 // The ACCESSOR case needs the receiver to be passed into C++ code, the FIELD |
| 585 // case might cause a miss during the prototype check. | 585 // case might cause a miss during the prototype check. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 | 632 |
| 633 // Leave the internal frame. | 633 // Leave the internal frame. |
| 634 } | 634 } |
| 635 | 635 |
| 636 GenerateLoadPostInterceptor(it, holder_reg); | 636 GenerateLoadPostInterceptor(it, holder_reg); |
| 637 } | 637 } |
| 638 | 638 |
| 639 | 639 |
| 640 void NamedLoadHandlerCompiler::GenerateLoadInterceptor(Register holder_reg) { | 640 void NamedLoadHandlerCompiler::GenerateLoadInterceptor(Register holder_reg) { |
| 641 DCHECK(holder()->HasNamedInterceptor()); | 641 DCHECK(holder()->HasNamedInterceptor()); |
| 642 DCHECK(!holder()->GetNamedInterceptor()->getter()->IsUndefined()); | 642 DCHECK(!holder()->GetNamedInterceptor()->getter()->IsUndefined(isolate())); |
| 643 // Call the runtime system to load the interceptor. | 643 // Call the runtime system to load the interceptor. |
| 644 __ pop(scratch2()); // save old return address | 644 __ pop(scratch2()); // save old return address |
| 645 PushInterceptorArguments(masm(), receiver(), holder_reg, this->name(), | 645 PushInterceptorArguments(masm(), receiver(), holder_reg, this->name(), |
| 646 holder()); | 646 holder()); |
| 647 __ push(scratch2()); // restore old return address | 647 __ push(scratch2()); // restore old return address |
| 648 | 648 |
| 649 __ TailCallRuntime(Runtime::kLoadPropertyWithInterceptor); | 649 __ TailCallRuntime(Runtime::kLoadPropertyWithInterceptor); |
| 650 } | 650 } |
| 651 | 651 |
| 652 | 652 |
| 653 Handle<Code> NamedStoreHandlerCompiler::CompileStoreCallback( | 653 Handle<Code> NamedStoreHandlerCompiler::CompileStoreCallback( |
| 654 Handle<JSObject> object, Handle<Name> name, Handle<AccessorInfo> callback, | 654 Handle<JSObject> object, Handle<Name> name, Handle<AccessorInfo> callback, |
| 655 LanguageMode language_mode) { | 655 LanguageMode language_mode) { |
| 656 Register holder_reg = Frontend(name); | 656 Register holder_reg = Frontend(name); |
| 657 | 657 |
| 658 __ pop(scratch1()); // remove the return address | 658 __ pop(scratch1()); // remove the return address |
| 659 __ push(receiver()); | 659 __ push(receiver()); |
| 660 __ push(holder_reg); | 660 __ push(holder_reg); |
| 661 // If the callback cannot leak, then push the callback directly, | 661 // If the callback cannot leak, then push the callback directly, |
| 662 // otherwise wrap it in a weak cell. | 662 // otherwise wrap it in a weak cell. |
| 663 if (callback->data()->IsUndefined() || callback->data()->IsSmi()) { | 663 if (callback->data()->IsUndefined(isolate()) || callback->data()->IsSmi()) { |
| 664 __ Push(callback); | 664 __ Push(callback); |
| 665 } else { | 665 } else { |
| 666 Handle<WeakCell> cell = isolate()->factory()->NewWeakCell(callback); | 666 Handle<WeakCell> cell = isolate()->factory()->NewWeakCell(callback); |
| 667 __ Push(cell); | 667 __ Push(cell); |
| 668 } | 668 } |
| 669 __ Push(name); | 669 __ Push(name); |
| 670 __ push(value()); | 670 __ push(value()); |
| 671 __ push(Immediate(Smi::FromInt(language_mode))); | 671 __ push(Immediate(Smi::FromInt(language_mode))); |
| 672 __ push(scratch1()); // restore return address | 672 __ push(scratch1()); // restore return address |
| 673 | 673 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 // Return the generated code. | 719 // Return the generated code. |
| 720 return GetCode(kind(), name); | 720 return GetCode(kind(), name); |
| 721 } | 721 } |
| 722 | 722 |
| 723 | 723 |
| 724 #undef __ | 724 #undef __ |
| 725 } // namespace internal | 725 } // namespace internal |
| 726 } // namespace v8 | 726 } // namespace v8 |
| 727 | 727 |
| 728 #endif // V8_TARGET_ARCH_X87 | 728 #endif // V8_TARGET_ARCH_X87 |
| OLD | NEW |