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

Side by Side Diff: src/x64/code-stubs-x64.cc

Issue 203173003: Array constructor expects AllocationSite or undefined as feedback. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Ports. Created 6 years, 9 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/x64/builtins-x64.cc ('k') | src/x64/lithium-codegen-x64.cc » ('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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 2193 matching lines...) Expand 10 before | Expand all | Expand 10 after
2204 if (NeedsChecks()) { 2204 if (NeedsChecks()) {
2205 // Check that the function really is a JavaScript function. 2205 // Check that the function really is a JavaScript function.
2206 __ JumpIfSmi(rdi, &non_function); 2206 __ JumpIfSmi(rdi, &non_function);
2207 2207
2208 // Goto slow case if we do not have a function. 2208 // Goto slow case if we do not have a function.
2209 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx); 2209 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx);
2210 __ j(not_equal, &slow); 2210 __ j(not_equal, &slow);
2211 2211
2212 if (RecordCallTarget()) { 2212 if (RecordCallTarget()) {
2213 GenerateRecordCallTarget(masm); 2213 GenerateRecordCallTarget(masm);
2214 // Type information was updated. Because we may call Array, which
2215 // expects either undefined or an AllocationSite in rbx we need
2216 // to set rbx to undefined.
2217 __ LoadRoot(rbx, Heap::kUndefinedValueRootIndex);
2214 } 2218 }
2215 } 2219 }
2216 2220
2217 // Fast-case: Just invoke the function. 2221 // Fast-case: Just invoke the function.
2218 ParameterCount actual(argc_); 2222 ParameterCount actual(argc_);
2219 2223
2220 if (CallAsMethod()) { 2224 if (CallAsMethod()) {
2221 if (NeedsChecks()) { 2225 if (NeedsChecks()) {
2222 // Do not transform the receiver for strict mode functions. 2226 // Do not transform the receiver for strict mode functions.
2223 __ movp(rcx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); 2227 __ movp(rcx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset));
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
2312 // rdi : constructor function 2316 // rdi : constructor function
2313 Label slow, non_function_call; 2317 Label slow, non_function_call;
2314 2318
2315 // Check that function is not a smi. 2319 // Check that function is not a smi.
2316 __ JumpIfSmi(rdi, &non_function_call); 2320 __ JumpIfSmi(rdi, &non_function_call);
2317 // Check that function is a JSFunction. 2321 // Check that function is a JSFunction.
2318 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx); 2322 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx);
2319 __ j(not_equal, &slow); 2323 __ j(not_equal, &slow);
2320 2324
2321 if (RecordCallTarget()) { 2325 if (RecordCallTarget()) {
2326 Label feedback_register_initialized;
2322 GenerateRecordCallTarget(masm); 2327 GenerateRecordCallTarget(masm);
2328 // Put the AllocationSite from the feedback vector into rbx, or undefined.
2329 __ SmiToInteger32(rdx, rdx);
2330 __ movp(rbx, FieldOperand(rbx, rdx, times_pointer_size,
2331 FixedArray::kHeaderSize));
2332 __ CompareRoot(FieldOperand(rbx, 0), Heap::kAllocationSiteMapRootIndex);
2333 __ j(equal, &feedback_register_initialized);
2334 __ LoadRoot(rbx, Heap::kUndefinedValueRootIndex);
2335 __ bind(&feedback_register_initialized);
2336 __ AssertUndefinedOrAllocationSite(rbx);
2323 } 2337 }
2324 2338
2325 // Jump to the function-specific construct stub. 2339 // Jump to the function-specific construct stub.
2326 Register jmp_reg = rcx; 2340 Register jmp_reg = rcx;
2327 __ movp(jmp_reg, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); 2341 __ movp(jmp_reg, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset));
2328 __ movp(jmp_reg, FieldOperand(jmp_reg, 2342 __ movp(jmp_reg, FieldOperand(jmp_reg,
2329 SharedFunctionInfo::kConstructStubOffset)); 2343 SharedFunctionInfo::kConstructStubOffset));
2330 __ lea(jmp_reg, FieldOperand(jmp_reg, Code::kHeaderSize)); 2344 __ lea(jmp_reg, FieldOperand(jmp_reg, Code::kHeaderSize));
2331 __ jmp(jmp_reg); 2345 __ jmp(jmp_reg);
2332 2346
(...skipping 2584 matching lines...) Expand 10 before | Expand all | Expand 10 after
4917 CreateArrayDispatch<ArrayNArgumentsConstructorStub>(masm, mode); 4931 CreateArrayDispatch<ArrayNArgumentsConstructorStub>(masm, mode);
4918 } else { 4932 } else {
4919 UNREACHABLE(); 4933 UNREACHABLE();
4920 } 4934 }
4921 } 4935 }
4922 4936
4923 4937
4924 void ArrayConstructorStub::Generate(MacroAssembler* masm) { 4938 void ArrayConstructorStub::Generate(MacroAssembler* masm) {
4925 // ----------- S t a t e ------------- 4939 // ----------- S t a t e -------------
4926 // -- rax : argc 4940 // -- rax : argc
4927 // -- rbx : feedback vector (fixed array or megamorphic symbol) 4941 // -- rbx : AllocationSite or undefined
4928 // -- rdx : slot index (if ebx is fixed array)
4929 // -- rdi : constructor 4942 // -- rdi : constructor
4930 // -- rsp[0] : return address 4943 // -- rsp[0] : return address
4931 // -- rsp[8] : last argument 4944 // -- rsp[8] : last argument
4932 // ----------------------------------- 4945 // -----------------------------------
4933 Handle<Object> megamorphic_sentinel =
4934 TypeFeedbackInfo::MegamorphicSentinel(masm->isolate());
4935
4936 if (FLAG_debug_code) { 4946 if (FLAG_debug_code) {
4937 // The array construct code is only set for the global and natives 4947 // The array construct code is only set for the global and natives
4938 // builtin Array functions which always have maps. 4948 // builtin Array functions which always have maps.
4939 4949
4940 // Initial map for the builtin Array function should be a map. 4950 // Initial map for the builtin Array function should be a map.
4941 __ movp(rcx, FieldOperand(rdi, JSFunction::kPrototypeOrInitialMapOffset)); 4951 __ movp(rcx, FieldOperand(rdi, JSFunction::kPrototypeOrInitialMapOffset));
4942 // Will both indicate a NULL and a Smi. 4952 // Will both indicate a NULL and a Smi.
4943 STATIC_ASSERT(kSmiTag == 0); 4953 STATIC_ASSERT(kSmiTag == 0);
4944 Condition not_smi = NegateCondition(masm->CheckSmi(rcx)); 4954 Condition not_smi = NegateCondition(masm->CheckSmi(rcx));
4945 __ Check(not_smi, kUnexpectedInitialMapForArrayFunction); 4955 __ Check(not_smi, kUnexpectedInitialMapForArrayFunction);
4946 __ CmpObjectType(rcx, MAP_TYPE, rcx); 4956 __ CmpObjectType(rcx, MAP_TYPE, rcx);
4947 __ Check(equal, kUnexpectedInitialMapForArrayFunction); 4957 __ Check(equal, kUnexpectedInitialMapForArrayFunction);
4948 4958
4949 // We should either have the megamorphic symbol in rbx or a valid 4959 // We should either have undefined in rbx or a valid AllocationSite
4950 // fixed array. 4960 __ AssertUndefinedOrAllocationSite(rbx);
4951 Label okay_here;
4952 Handle<Map> fixed_array_map = masm->isolate()->factory()->fixed_array_map();
4953 __ Cmp(rbx, megamorphic_sentinel);
4954 __ j(equal, &okay_here);
4955 __ Cmp(FieldOperand(rbx, 0), fixed_array_map);
4956 __ Assert(equal, kExpectedFixedArrayInRegisterRbx);
4957
4958 // rdx should be a smi if we don't have the megamorphic symbol in rbx.
4959 __ AssertSmi(rdx);
4960
4961 __ bind(&okay_here);
4962 } 4961 }
4963 4962
4964 Label no_info; 4963 Label no_info;
4965 // If the feedback slot is the megamorphic sentinel, or contains anything 4964 // If the feedback slot is the megamorphic sentinel, or contains anything
4966 // other than an AllocationSite, call an array constructor that doesn't use 4965 // other than an AllocationSite, call an array constructor that doesn't use
4967 // AllocationSites. 4966 // AllocationSites.
4968 __ Cmp(rbx, megamorphic_sentinel); 4967 __ CompareRoot(rbx, Heap::kUndefinedValueRootIndex);
4969 __ j(equal, &no_info); 4968 __ j(equal, &no_info);
4970 __ SmiToInteger32(rdx, rdx);
4971 __ movp(rbx, FieldOperand(rbx, rdx, times_pointer_size,
4972 FixedArray::kHeaderSize));
4973 __ Integer32ToSmi(rdx, rdx);
4974 __ Cmp(FieldOperand(rbx, 0),
4975 masm->isolate()->factory()->allocation_site_map());
4976 __ j(not_equal, &no_info);
4977 4969
4978 // Only look at the lower 16 bits of the transition info. 4970 // Only look at the lower 16 bits of the transition info.
4979 __ movp(rdx, FieldOperand(rbx, AllocationSite::kTransitionInfoOffset)); 4971 __ movp(rdx, FieldOperand(rbx, AllocationSite::kTransitionInfoOffset));
4980 __ SmiToInteger32(rdx, rdx); 4972 __ SmiToInteger32(rdx, rdx);
4981 STATIC_ASSERT(AllocationSite::ElementsKindBits::kShift == 0); 4973 STATIC_ASSERT(AllocationSite::ElementsKindBits::kShift == 0);
4982 __ and_(rdx, Immediate(AllocationSite::ElementsKindBits::kMask)); 4974 __ and_(rdx, Immediate(AllocationSite::ElementsKindBits::kMask));
4983 GenerateDispatchToArrayStub(masm, DONT_OVERRIDE); 4975 GenerateDispatchToArrayStub(masm, DONT_OVERRIDE);
4984 4976
4985 __ bind(&no_info); 4977 __ bind(&no_info);
4986 GenerateDispatchToArrayStub(masm, DISABLE_ALLOCATION_SITES); 4978 GenerateDispatchToArrayStub(masm, DISABLE_ALLOCATION_SITES);
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
5251 return_value_operand, 5243 return_value_operand,
5252 NULL); 5244 NULL);
5253 } 5245 }
5254 5246
5255 5247
5256 #undef __ 5248 #undef __
5257 5249
5258 } } // namespace v8::internal 5250 } } // namespace v8::internal
5259 5251
5260 #endif // V8_TARGET_ARCH_X64 5252 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/builtins-x64.cc ('k') | src/x64/lithium-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698