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

Side by Side Diff: src/ia32/lithium-codegen-ia32.cc

Issue 132623005: A64: Synchronize with r18642. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « src/ia32/lithium-codegen-ia32.h ('k') | src/ia32/lithium-ia32.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 } 175 }
176 #endif 176 #endif
177 177
178 // Classic mode functions and builtins need to replace the receiver with the 178 // Classic mode functions and builtins need to replace the receiver with the
179 // global proxy when called as functions (without an explicit receiver 179 // global proxy when called as functions (without an explicit receiver
180 // object). 180 // object).
181 if (info_->this_has_uses() && 181 if (info_->this_has_uses() &&
182 info_->is_classic_mode() && 182 info_->is_classic_mode() &&
183 !info_->is_native()) { 183 !info_->is_native()) {
184 Label ok; 184 Label ok;
185 __ test(ecx, ecx);
186 __ j(zero, &ok, Label::kNear);
187
188 // +1 for return address. 185 // +1 for return address.
189 int receiver_offset = (scope()->num_parameters() + 1) * kPointerSize; 186 int receiver_offset = (scope()->num_parameters() + 1) * kPointerSize;
190 __ mov(ecx, Operand(esp, receiver_offset)); 187 __ mov(ecx, Operand(esp, receiver_offset));
191 188
192 __ cmp(ecx, isolate()->factory()->undefined_value()); 189 __ cmp(ecx, isolate()->factory()->undefined_value());
193 __ j(not_equal, &ok, Label::kNear); 190 __ j(not_equal, &ok, Label::kNear);
194 191
195 __ mov(ecx, GlobalObjectOperand()); 192 __ mov(ecx, GlobalObjectOperand());
196 __ mov(ecx, FieldOperand(ecx, GlobalObject::kGlobalReceiverOffset)); 193 __ mov(ecx, FieldOperand(ecx, GlobalObject::kGlobalReceiverOffset));
197 194
(...skipping 3521 matching lines...) Expand 10 before | Expand all | Expand 10 after
3719 __ dec(length); 3716 __ dec(length);
3720 __ j(not_zero, &loop); 3717 __ j(not_zero, &loop);
3721 3718
3722 // Invoke the function. 3719 // Invoke the function.
3723 __ bind(&invoke); 3720 __ bind(&invoke);
3724 ASSERT(instr->HasPointerMap()); 3721 ASSERT(instr->HasPointerMap());
3725 LPointerMap* pointers = instr->pointer_map(); 3722 LPointerMap* pointers = instr->pointer_map();
3726 SafepointGenerator safepoint_generator( 3723 SafepointGenerator safepoint_generator(
3727 this, pointers, Safepoint::kLazyDeopt); 3724 this, pointers, Safepoint::kLazyDeopt);
3728 ParameterCount actual(eax); 3725 ParameterCount actual(eax);
3729 __ InvokeFunction(function, actual, CALL_FUNCTION, 3726 __ InvokeFunction(function, actual, CALL_FUNCTION, safepoint_generator);
3730 safepoint_generator, CALL_AS_FUNCTION);
3731 } 3727 }
3732 3728
3733 3729
3734 void LCodeGen::DoDebugBreak(LDebugBreak* instr) { 3730 void LCodeGen::DoDebugBreak(LDebugBreak* instr) {
3735 __ int3(); 3731 __ int3();
3736 } 3732 }
3737 3733
3738 3734
3739 void LCodeGen::DoPushArgument(LPushArgument* instr) { 3735 void LCodeGen::DoPushArgument(LPushArgument* instr) {
3740 LOperand* argument = instr->value(); 3736 LOperand* argument = instr->value();
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
3793 Register global = ToRegister(instr->global()); 3789 Register global = ToRegister(instr->global());
3794 Register result = ToRegister(instr->result()); 3790 Register result = ToRegister(instr->result());
3795 __ mov(result, FieldOperand(global, GlobalObject::kGlobalReceiverOffset)); 3791 __ mov(result, FieldOperand(global, GlobalObject::kGlobalReceiverOffset));
3796 } 3792 }
3797 3793
3798 3794
3799 void LCodeGen::CallKnownFunction(Handle<JSFunction> function, 3795 void LCodeGen::CallKnownFunction(Handle<JSFunction> function,
3800 int formal_parameter_count, 3796 int formal_parameter_count,
3801 int arity, 3797 int arity,
3802 LInstruction* instr, 3798 LInstruction* instr,
3803 CallKind call_kind,
3804 EDIState edi_state) { 3799 EDIState edi_state) {
3805 bool dont_adapt_arguments = 3800 bool dont_adapt_arguments =
3806 formal_parameter_count == SharedFunctionInfo::kDontAdaptArgumentsSentinel; 3801 formal_parameter_count == SharedFunctionInfo::kDontAdaptArgumentsSentinel;
3807 bool can_invoke_directly = 3802 bool can_invoke_directly =
3808 dont_adapt_arguments || formal_parameter_count == arity; 3803 dont_adapt_arguments || formal_parameter_count == arity;
3809 3804
3810 if (can_invoke_directly) { 3805 if (can_invoke_directly) {
3811 if (edi_state == EDI_UNINITIALIZED) { 3806 if (edi_state == EDI_UNINITIALIZED) {
3812 __ LoadHeapObject(edi, function); 3807 __ LoadHeapObject(edi, function);
3813 } 3808 }
3814 3809
3815 // Change context. 3810 // Change context.
3816 __ mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); 3811 __ mov(esi, FieldOperand(edi, JSFunction::kContextOffset));
3817 3812
3818 // Set eax to arguments count if adaption is not needed. Assumes that eax 3813 // Set eax to arguments count if adaption is not needed. Assumes that eax
3819 // is available to write to at this point. 3814 // is available to write to at this point.
3820 if (dont_adapt_arguments) { 3815 if (dont_adapt_arguments) {
3821 __ mov(eax, arity); 3816 __ mov(eax, arity);
3822 } 3817 }
3823 3818
3824 // Invoke function directly. 3819 // Invoke function directly.
3825 __ SetCallKind(ecx, call_kind);
3826 if (function.is_identical_to(info()->closure())) { 3820 if (function.is_identical_to(info()->closure())) {
3827 __ CallSelf(); 3821 __ CallSelf();
3828 } else { 3822 } else {
3829 __ call(FieldOperand(edi, JSFunction::kCodeEntryOffset)); 3823 __ call(FieldOperand(edi, JSFunction::kCodeEntryOffset));
3830 } 3824 }
3831 RecordSafepointWithLazyDeopt(instr, RECORD_SIMPLE_SAFEPOINT); 3825 RecordSafepointWithLazyDeopt(instr, RECORD_SIMPLE_SAFEPOINT);
3832 } else { 3826 } else {
3833 // We need to adapt arguments. 3827 // We need to adapt arguments.
3834 LPointerMap* pointers = instr->pointer_map(); 3828 LPointerMap* pointers = instr->pointer_map();
3835 SafepointGenerator generator( 3829 SafepointGenerator generator(
3836 this, pointers, Safepoint::kLazyDeopt); 3830 this, pointers, Safepoint::kLazyDeopt);
3837 ParameterCount count(arity); 3831 ParameterCount count(arity);
3838 ParameterCount expected(formal_parameter_count); 3832 ParameterCount expected(formal_parameter_count);
3839 __ InvokeFunction( 3833 __ InvokeFunction(function, expected, count, CALL_FUNCTION, generator);
3840 function, expected, count, CALL_FUNCTION, generator, call_kind);
3841 } 3834 }
3842 } 3835 }
3843 3836
3844 3837
3845 void LCodeGen::DoCallConstantFunction(LCallConstantFunction* instr) { 3838 void LCodeGen::DoCallWithDescriptor(LCallWithDescriptor* instr) {
3846 ASSERT(ToRegister(instr->result()).is(eax)); 3839 ASSERT(ToRegister(instr->result()).is(eax));
3847 CallKnownFunction(instr->hydrogen()->function(), 3840
3848 instr->hydrogen()->formal_parameter_count(), 3841 LPointerMap* pointers = instr->pointer_map();
3849 instr->arity(), 3842 SafepointGenerator generator(this, pointers, Safepoint::kLazyDeopt);
3850 instr, 3843
3851 CALL_AS_FUNCTION, 3844 if (instr->target()->IsConstantOperand()) {
3852 EDI_UNINITIALIZED); 3845 LConstantOperand* target = LConstantOperand::cast(instr->target());
3846 Handle<Code> code = Handle<Code>::cast(ToHandle(target));
3847 generator.BeforeCall(__ CallSize(code, RelocInfo::CODE_TARGET));
3848 __ call(code, RelocInfo::CODE_TARGET);
3849 } else {
3850 ASSERT(instr->target()->IsRegister());
3851 Register target = ToRegister(instr->target());
3852 generator.BeforeCall(__ CallSize(Operand(target)));
3853 __ add(target, Immediate(Code::kHeaderSize - kHeapObjectTag));
3854 __ call(target);
3855 }
3856 generator.AfterCall();
3853 } 3857 }
3854 3858
3855 3859
3860 void LCodeGen::DoCallJSFunction(LCallJSFunction* instr) {
3861 ASSERT(ToRegister(instr->function()).is(edi));
3862 ASSERT(ToRegister(instr->result()).is(eax));
3863
3864 if (instr->hydrogen()->pass_argument_count()) {
3865 __ mov(eax, instr->arity());
3866 }
3867
3868 // Change context.
3869 __ mov(esi, FieldOperand(edi, JSFunction::kContextOffset));
3870
3871 bool is_self_call = false;
3872 if (instr->hydrogen()->function()->IsConstant()) {
3873 HConstant* fun_const = HConstant::cast(instr->hydrogen()->function());
3874 Handle<JSFunction> jsfun =
3875 Handle<JSFunction>::cast(fun_const->handle(isolate()));
3876 is_self_call = jsfun.is_identical_to(info()->closure());
3877 }
3878
3879 if (is_self_call) {
3880 __ CallSelf();
3881 } else {
3882 __ call(FieldOperand(edi, JSFunction::kCodeEntryOffset));
3883 }
3884
3885 RecordSafepointWithLazyDeopt(instr, RECORD_SIMPLE_SAFEPOINT);
3886 }
3887
3888
3856 void LCodeGen::DoDeferredMathAbsTaggedHeapNumber(LMathAbs* instr) { 3889 void LCodeGen::DoDeferredMathAbsTaggedHeapNumber(LMathAbs* instr) {
3857 Register input_reg = ToRegister(instr->value()); 3890 Register input_reg = ToRegister(instr->value());
3858 __ cmp(FieldOperand(input_reg, HeapObject::kMapOffset), 3891 __ cmp(FieldOperand(input_reg, HeapObject::kMapOffset),
3859 factory()->heap_number_map()); 3892 factory()->heap_number_map());
3860 DeoptimizeIf(not_equal, instr->environment()); 3893 DeoptimizeIf(not_equal, instr->environment());
3861 3894
3862 Label slow, allocated, done; 3895 Label slow, allocated, done;
3863 Register tmp = input_reg.is(eax) ? ecx : eax; 3896 Register tmp = input_reg.is(eax) ? ecx : eax;
3864 Register tmp2 = tmp.is(ecx) ? edx : input_reg.is(ecx) ? edx : ecx; 3897 Register tmp2 = tmp.is(ecx) ? edx : input_reg.is(ecx) ? edx : ecx;
3865 3898
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
4202 ASSERT(ToRegister(instr->context()).is(esi)); 4235 ASSERT(ToRegister(instr->context()).is(esi));
4203 ASSERT(ToRegister(instr->function()).is(edi)); 4236 ASSERT(ToRegister(instr->function()).is(edi));
4204 ASSERT(instr->HasPointerMap()); 4237 ASSERT(instr->HasPointerMap());
4205 4238
4206 Handle<JSFunction> known_function = instr->hydrogen()->known_function(); 4239 Handle<JSFunction> known_function = instr->hydrogen()->known_function();
4207 if (known_function.is_null()) { 4240 if (known_function.is_null()) {
4208 LPointerMap* pointers = instr->pointer_map(); 4241 LPointerMap* pointers = instr->pointer_map();
4209 SafepointGenerator generator( 4242 SafepointGenerator generator(
4210 this, pointers, Safepoint::kLazyDeopt); 4243 this, pointers, Safepoint::kLazyDeopt);
4211 ParameterCount count(instr->arity()); 4244 ParameterCount count(instr->arity());
4212 __ InvokeFunction(edi, count, CALL_FUNCTION, generator, CALL_AS_FUNCTION); 4245 __ InvokeFunction(edi, count, CALL_FUNCTION, generator);
4213 } else { 4246 } else {
4214 CallKnownFunction(known_function, 4247 CallKnownFunction(known_function,
4215 instr->hydrogen()->formal_parameter_count(), 4248 instr->hydrogen()->formal_parameter_count(),
4216 instr->arity(), 4249 instr->arity(),
4217 instr, 4250 instr,
4218 CALL_AS_FUNCTION,
4219 EDI_CONTAINS_TARGET); 4251 EDI_CONTAINS_TARGET);
4220 } 4252 }
4221 } 4253 }
4222 4254
4223 4255
4224 void LCodeGen::DoCallKeyed(LCallKeyed* instr) {
4225 ASSERT(ToRegister(instr->context()).is(esi));
4226 ASSERT(ToRegister(instr->key()).is(ecx));
4227 ASSERT(ToRegister(instr->result()).is(eax));
4228
4229 int arity = instr->arity();
4230 Handle<Code> ic =
4231 isolate()->stub_cache()->ComputeKeyedCallInitialize(arity);
4232 CallCode(ic, RelocInfo::CODE_TARGET, instr);
4233 }
4234
4235
4236 void LCodeGen::DoCallNamed(LCallNamed* instr) {
4237 ASSERT(ToRegister(instr->context()).is(esi));
4238 ASSERT(ToRegister(instr->result()).is(eax));
4239
4240 int arity = instr->arity();
4241 Handle<Code> ic =
4242 isolate()->stub_cache()->ComputeCallInitialize(arity, NOT_CONTEXTUAL);
4243 __ mov(ecx, instr->name());
4244 CallCode(ic, RelocInfo::CODE_TARGET, instr);
4245 }
4246
4247
4248 void LCodeGen::DoCallFunction(LCallFunction* instr) { 4256 void LCodeGen::DoCallFunction(LCallFunction* instr) {
4249 ASSERT(ToRegister(instr->context()).is(esi)); 4257 ASSERT(ToRegister(instr->context()).is(esi));
4250 ASSERT(ToRegister(instr->function()).is(edi)); 4258 ASSERT(ToRegister(instr->function()).is(edi));
4251 ASSERT(ToRegister(instr->result()).is(eax)); 4259 ASSERT(ToRegister(instr->result()).is(eax));
4252 4260
4253 int arity = instr->arity(); 4261 int arity = instr->arity();
4254 CallFunctionStub stub(arity, NO_CALL_FUNCTION_FLAGS); 4262 CallFunctionStub stub(arity, NO_CALL_FUNCTION_FLAGS);
4255 if (instr->hydrogen()->IsTailCall()) { 4263 if (instr->hydrogen()->IsTailCall()) {
4256 if (NeedsEagerFrame()) __ leave(); 4264 if (NeedsEagerFrame()) __ leave();
4257 __ jmp(stub.GetCode(isolate()), RelocInfo::CODE_TARGET); 4265 __ jmp(stub.GetCode(isolate()), RelocInfo::CODE_TARGET);
4258 } else { 4266 } else {
4259 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); 4267 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr);
4260 } 4268 }
4261 } 4269 }
4262 4270
4263 4271
4264 void LCodeGen::DoCallGlobal(LCallGlobal* instr) {
4265 ASSERT(ToRegister(instr->context()).is(esi));
4266 ASSERT(ToRegister(instr->result()).is(eax));
4267
4268 int arity = instr->arity();
4269 Handle<Code> ic =
4270 isolate()->stub_cache()->ComputeCallInitialize(arity, CONTEXTUAL);
4271 __ mov(ecx, instr->name());
4272 CallCode(ic, RelocInfo::CODE_TARGET, instr);
4273 }
4274
4275
4276 void LCodeGen::DoCallKnownGlobal(LCallKnownGlobal* instr) {
4277 ASSERT(ToRegister(instr->result()).is(eax));
4278 CallKnownFunction(instr->hydrogen()->target(),
4279 instr->hydrogen()->formal_parameter_count(),
4280 instr->arity(),
4281 instr,
4282 CALL_AS_FUNCTION,
4283 EDI_UNINITIALIZED);
4284 }
4285
4286
4287 void LCodeGen::DoCallNew(LCallNew* instr) { 4272 void LCodeGen::DoCallNew(LCallNew* instr) {
4288 ASSERT(ToRegister(instr->context()).is(esi)); 4273 ASSERT(ToRegister(instr->context()).is(esi));
4289 ASSERT(ToRegister(instr->constructor()).is(edi)); 4274 ASSERT(ToRegister(instr->constructor()).is(edi));
4290 ASSERT(ToRegister(instr->result()).is(eax)); 4275 ASSERT(ToRegister(instr->result()).is(eax));
4291 4276
4292 // No cell in ebx for construct type feedback in optimized code 4277 // No cell in ebx for construct type feedback in optimized code
4293 Handle<Object> undefined_value(isolate()->factory()->undefined_value()); 4278 Handle<Object> undefined_value(isolate()->factory()->undefined_value());
4294 __ mov(ebx, Immediate(undefined_value)); 4279 __ mov(ebx, Immediate(undefined_value));
4295 CallConstructStub stub(NO_CALL_FUNCTION_FLAGS); 4280 CallConstructStub stub(NO_CALL_FUNCTION_FLAGS);
4296 __ Set(eax, Immediate(instr->arity())); 4281 __ Set(eax, Immediate(instr->arity()));
(...skipping 1301 matching lines...) Expand 10 before | Expand all | Expand 10 after
5598 } 5583 }
5599 DeoptimizeIf(not_equal, instr->environment()); 5584 DeoptimizeIf(not_equal, instr->environment());
5600 } 5585 }
5601 5586
5602 5587
5603 void LCodeGen::DoDeferredInstanceMigration(LCheckMaps* instr, Register object) { 5588 void LCodeGen::DoDeferredInstanceMigration(LCheckMaps* instr, Register object) {
5604 { 5589 {
5605 PushSafepointRegistersScope scope(this); 5590 PushSafepointRegistersScope scope(this);
5606 __ push(object); 5591 __ push(object);
5607 __ xor_(esi, esi); 5592 __ xor_(esi, esi);
5608 __ CallRuntimeSaveDoubles(Runtime::kMigrateInstance); 5593 __ CallRuntimeSaveDoubles(Runtime::kTryMigrateInstance);
5609 RecordSafepointWithRegisters( 5594 RecordSafepointWithRegisters(
5610 instr->pointer_map(), 1, Safepoint::kNoLazyDeopt); 5595 instr->pointer_map(), 1, Safepoint::kNoLazyDeopt);
5611 5596
5612 __ test(eax, Immediate(kSmiTagMask)); 5597 __ test(eax, Immediate(kSmiTagMask));
5613 } 5598 }
5614 DeoptimizeIf(zero, instr->environment()); 5599 DeoptimizeIf(zero, instr->environment());
5615 } 5600 }
5616 5601
5617 5602
5618 void LCodeGen::DoCheckMaps(LCheckMaps* instr) { 5603 void LCodeGen::DoCheckMaps(LCheckMaps* instr) {
(...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after
6366 FixedArray::kHeaderSize - kPointerSize)); 6351 FixedArray::kHeaderSize - kPointerSize));
6367 __ bind(&done); 6352 __ bind(&done);
6368 } 6353 }
6369 6354
6370 6355
6371 #undef __ 6356 #undef __
6372 6357
6373 } } // namespace v8::internal 6358 } } // namespace v8::internal
6374 6359
6375 #endif // V8_TARGET_ARCH_IA32 6360 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/lithium-codegen-ia32.h ('k') | src/ia32/lithium-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698