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

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

Issue 137403009: Adding a type vector to replace type cells. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: PORTS. 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
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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 descriptor->register_param_count_ = 4; 99 descriptor->register_param_count_ = 4;
100 descriptor->register_params_ = registers; 100 descriptor->register_params_ = registers;
101 descriptor->deoptimization_handler_ = 101 descriptor->deoptimization_handler_ =
102 Runtime::FunctionForId(Runtime::kCreateObjectLiteral)->entry; 102 Runtime::FunctionForId(Runtime::kCreateObjectLiteral)->entry;
103 } 103 }
104 104
105 105
106 void CreateAllocationSiteStub::InitializeInterfaceDescriptor( 106 void CreateAllocationSiteStub::InitializeInterfaceDescriptor(
107 Isolate* isolate, 107 Isolate* isolate,
108 CodeStubInterfaceDescriptor* descriptor) { 108 CodeStubInterfaceDescriptor* descriptor) {
109 static Register registers[] = { rbx }; 109 static Register registers[] = { rbx, rdx };
110 descriptor->register_param_count_ = 1; 110 descriptor->register_param_count_ = 2;
111 descriptor->register_params_ = registers; 111 descriptor->register_params_ = registers;
112 descriptor->deoptimization_handler_ = NULL; 112 descriptor->deoptimization_handler_ = NULL;
113 } 113 }
114 114
115 115
116 void KeyedLoadFastElementStub::InitializeInterfaceDescriptor( 116 void KeyedLoadFastElementStub::InitializeInterfaceDescriptor(
117 Isolate* isolate, 117 Isolate* isolate,
118 CodeStubInterfaceDescriptor* descriptor) { 118 CodeStubInterfaceDescriptor* descriptor) {
119 static Register registers[] = { rdx, rax }; 119 static Register registers[] = { rdx, rax };
120 descriptor->register_param_count_ = 2; 120 descriptor->register_param_count_ = 2;
(...skipping 2050 matching lines...) Expand 10 before | Expand all | Expand 10 after
2171 __ bind(&miss); 2171 __ bind(&miss);
2172 GenerateMiss(masm); 2172 GenerateMiss(masm);
2173 } 2173 }
2174 2174
2175 2175
2176 static void GenerateRecordCallTarget(MacroAssembler* masm) { 2176 static void GenerateRecordCallTarget(MacroAssembler* masm) {
2177 // Cache the called function in a global property cell. Cache states 2177 // Cache the called function in a global property cell. Cache states
2178 // are uninitialized, monomorphic (indicated by a JSFunction), and 2178 // are uninitialized, monomorphic (indicated by a JSFunction), and
2179 // megamorphic. 2179 // megamorphic.
2180 // rax : number of arguments to the construct function 2180 // rax : number of arguments to the construct function
2181 // rbx : cache cell for call target 2181 // rbx : Feedback vector
2182 // rdx : slot in feedback vector (Smi)
2182 // rdi : the function to call 2183 // rdi : the function to call
2183 Isolate* isolate = masm->isolate(); 2184 Isolate* isolate = masm->isolate();
2184 Label initialize, done, miss, megamorphic, not_array_function; 2185 Label initialize, done, miss, megamorphic, not_array_function,
2186 done_no_smi_convert;
2185 2187
2186 // Load the cache state into rcx. 2188 // Load the cache state into rcx.
2187 __ movp(rcx, FieldOperand(rbx, Cell::kValueOffset)); 2189 __ SmiToInteger32(rdx, rdx);
2190 __ movp(rcx, FieldOperand(rbx, rdx, times_pointer_size,
2191 FixedArray::kHeaderSize));
2188 2192
2189 // A monomorphic cache hit or an already megamorphic state: invoke the 2193 // A monomorphic cache hit or an already megamorphic state: invoke the
2190 // function without changing the state. 2194 // function without changing the state.
2191 __ cmpq(rcx, rdi); 2195 __ cmpq(rcx, rdi);
2192 __ j(equal, &done); 2196 __ j(equal, &done);
2193 __ Cmp(rcx, TypeFeedbackCells::MegamorphicSentinel(isolate)); 2197 __ Cmp(rcx, TypeFeedbackInfo::MegamorphicSentinel(isolate));
2194 __ j(equal, &done); 2198 __ j(equal, &done);
2195 2199
2196 // If we came here, we need to see if we are the array function. 2200 // If we came here, we need to see if we are the array function.
2197 // If we didn't have a matching function, and we didn't find the megamorph 2201 // If we didn't have a matching function, and we didn't find the megamorph
2198 // sentinel, then we have in the cell either some other function or an 2202 // sentinel, then we have in the cell either some other function or an
2199 // AllocationSite. Do a map check on the object in rcx. 2203 // AllocationSite. Do a map check on the object in rcx.
2200 Handle<Map> allocation_site_map = 2204 Handle<Map> allocation_site_map =
2201 masm->isolate()->factory()->allocation_site_map(); 2205 masm->isolate()->factory()->allocation_site_map();
2202 __ Cmp(FieldOperand(rcx, 0), allocation_site_map); 2206 __ Cmp(FieldOperand(rcx, 0), allocation_site_map);
2203 __ j(not_equal, &miss); 2207 __ j(not_equal, &miss);
2204 2208
2205 // Make sure the function is the Array() function 2209 // Make sure the function is the Array() function
2206 __ LoadArrayFunction(rcx); 2210 __ LoadArrayFunction(rcx);
2207 __ cmpq(rdi, rcx); 2211 __ cmpq(rdi, rcx);
2208 __ j(not_equal, &megamorphic); 2212 __ j(not_equal, &megamorphic);
2209 __ jmp(&done); 2213 __ jmp(&done);
2210 2214
2211 __ bind(&miss); 2215 __ bind(&miss);
2212 2216
2213 // A monomorphic miss (i.e, here the cache is not uninitialized) goes 2217 // A monomorphic miss (i.e, here the cache is not uninitialized) goes
2214 // megamorphic. 2218 // megamorphic.
2215 __ Cmp(rcx, TypeFeedbackCells::UninitializedSentinel(isolate)); 2219 __ Cmp(rcx, TypeFeedbackInfo::UninitializedSentinel(isolate));
2216 __ j(equal, &initialize); 2220 __ j(equal, &initialize);
2217 // MegamorphicSentinel is an immortal immovable object (undefined) so no 2221 // MegamorphicSentinel is an immortal immovable object (undefined) so no
2218 // write-barrier is needed. 2222 // write-barrier is needed.
2219 __ bind(&megamorphic); 2223 __ bind(&megamorphic);
2220 __ Move(FieldOperand(rbx, Cell::kValueOffset), 2224 __ Move(FieldOperand(rbx, rdx, times_pointer_size, FixedArray::kHeaderSize),
2221 TypeFeedbackCells::MegamorphicSentinel(isolate)); 2225 TypeFeedbackInfo::MegamorphicSentinel(isolate));
2222 __ jmp(&done); 2226 __ jmp(&done);
2223 2227
2224 // An uninitialized cache is patched with the function or sentinel to 2228 // An uninitialized cache is patched with the function or sentinel to
2225 // indicate the ElementsKind if function is the Array constructor. 2229 // indicate the ElementsKind if function is the Array constructor.
2226 __ bind(&initialize); 2230 __ bind(&initialize);
2227 // Make sure the function is the Array() function 2231 // Make sure the function is the Array() function
2228 __ LoadArrayFunction(rcx); 2232 __ LoadArrayFunction(rcx);
2229 __ cmpq(rdi, rcx); 2233 __ cmpq(rdi, rcx);
2230 __ j(not_equal, &not_array_function); 2234 __ j(not_equal, &not_array_function);
2231 2235
2232 // The target function is the Array constructor, 2236 // The target function is the Array constructor,
2233 // Create an AllocationSite if we don't already have it, store it in the cell 2237 // Create an AllocationSite if we don't already have it, store it in the cell
2234 { 2238 {
2235 FrameScope scope(masm, StackFrame::INTERNAL); 2239 FrameScope scope(masm, StackFrame::INTERNAL);
2236 2240
2237 // Arguments register must be smi-tagged to call out. 2241 // Arguments register must be smi-tagged to call out.
2238 __ Integer32ToSmi(rax, rax); 2242 __ Integer32ToSmi(rax, rax);
2239 __ push(rax); 2243 __ push(rax);
2240 __ push(rdi); 2244 __ push(rdi);
2245 __ Integer32ToSmi(rdx, rdx);
2246 __ push(rdx);
2241 __ push(rbx); 2247 __ push(rbx);
2242 2248
2243 CreateAllocationSiteStub create_stub; 2249 CreateAllocationSiteStub create_stub;
2244 __ CallStub(&create_stub); 2250 __ CallStub(&create_stub);
2245 2251
2246 __ pop(rbx); 2252 __ pop(rbx);
2253 __ pop(rdx);
2247 __ pop(rdi); 2254 __ pop(rdi);
2248 __ pop(rax); 2255 __ pop(rax);
2249 __ SmiToInteger32(rax, rax); 2256 __ SmiToInteger32(rax, rax);
2250 } 2257 }
2251 __ jmp(&done); 2258 __ jmp(&done_no_smi_convert);
2252 2259
2253 __ bind(&not_array_function); 2260 __ bind(&not_array_function);
2254 __ movp(FieldOperand(rbx, Cell::kValueOffset), rdi); 2261 __ movp(FieldOperand(rbx, rdx, times_pointer_size, FixedArray::kHeaderSize),
2255 // No need for a write barrier here - cells are rescanned. 2262 rdi);
2263
2264 // We won't need rdx or rbx anymore, just save rdi
2265 __ push(rdi);
2266 __ push(rbx);
2267 __ push(rdx);
2268 __ RecordWriteArray(rbx, rdi, rdx, kDontSaveFPRegs,
2269 EMIT_REMEMBERED_SET, OMIT_SMI_CHECK);
2270 __ pop(rdx);
2271 __ pop(rbx);
2272 __ pop(rdi);
2256 2273
2257 __ bind(&done); 2274 __ bind(&done);
2275 __ Integer32ToSmi(rdx, rdx);
2276
2277 __ bind(&done_no_smi_convert);
2258 } 2278 }
2259 2279
2260 2280
2261 void CallFunctionStub::Generate(MacroAssembler* masm) { 2281 void CallFunctionStub::Generate(MacroAssembler* masm) {
2262 // rbx : cache cell for call target 2282 // rbx : feedback vector
2283 // rdx : (only if rbx is not undefined) slot in feedback vector (Smi)
2263 // rdi : the function to call 2284 // rdi : the function to call
2264 Isolate* isolate = masm->isolate(); 2285 Isolate* isolate = masm->isolate();
2265 Label slow, non_function; 2286 Label slow, non_function;
2266 StackArgumentsAccessor args(rsp, argc_); 2287 StackArgumentsAccessor args(rsp, argc_);
2267 2288
2268 // Check that the function really is a JavaScript function. 2289 // Check that the function really is a JavaScript function.
2269 __ JumpIfSmi(rdi, &non_function); 2290 __ JumpIfSmi(rdi, &non_function);
2270 2291
2271 // Goto slow case if we do not have a function. 2292 // Goto slow case if we do not have a function.
2272 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx); 2293 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx);
2273 __ j(not_equal, &slow); 2294 __ j(not_equal, &slow);
2274 2295
2275 if (RecordCallTarget()) { 2296 if (RecordCallTarget()) {
2276 GenerateRecordCallTarget(masm); 2297 GenerateRecordCallTarget(masm);
2277 } 2298 }
2278 2299
2279 // Fast-case: Just invoke the function. 2300 // Fast-case: Just invoke the function.
2280 ParameterCount actual(argc_); 2301 ParameterCount actual(argc_);
2281 2302
2282 __ InvokeFunction(rdi, actual, JUMP_FUNCTION, NullCallWrapper()); 2303 __ InvokeFunction(rdi, actual, JUMP_FUNCTION, NullCallWrapper());
2283 2304
2284 // Slow-case: Non-function called. 2305 // Slow-case: Non-function called.
2285 __ bind(&slow); 2306 __ bind(&slow);
2286 if (RecordCallTarget()) { 2307 if (RecordCallTarget()) {
2287 // If there is a call target cache, mark it megamorphic in the 2308 // If there is a call target cache, mark it megamorphic in the
2288 // non-function case. MegamorphicSentinel is an immortal immovable 2309 // non-function case. MegamorphicSentinel is an immortal immovable
2289 // object (undefined) so no write barrier is needed. 2310 // object (undefined) so no write barrier is needed.
2290 __ Move(FieldOperand(rbx, Cell::kValueOffset), 2311 __ SmiToInteger32(rdx, rdx);
2291 TypeFeedbackCells::MegamorphicSentinel(isolate)); 2312 __ Move(FieldOperand(rbx, rdx, times_pointer_size, FixedArray::kHeaderSize),
2313 TypeFeedbackInfo::MegamorphicSentinel(isolate));
2314 __ Integer32ToSmi(rdx, rdx);
2292 } 2315 }
2293 // Check for function proxy. 2316 // Check for function proxy.
2294 __ CmpInstanceType(rcx, JS_FUNCTION_PROXY_TYPE); 2317 __ CmpInstanceType(rcx, JS_FUNCTION_PROXY_TYPE);
2295 __ j(not_equal, &non_function); 2318 __ j(not_equal, &non_function);
2296 __ PopReturnAddressTo(rcx); 2319 __ PopReturnAddressTo(rcx);
2297 __ push(rdi); // put proxy as additional argument under return address 2320 __ push(rdi); // put proxy as additional argument under return address
2298 __ PushReturnAddressFrom(rcx); 2321 __ PushReturnAddressFrom(rcx);
2299 __ Set(rax, argc_ + 1); 2322 __ Set(rax, argc_ + 1);
2300 __ Set(rbx, 0); 2323 __ Set(rbx, 0);
2301 __ GetBuiltinEntry(rdx, Builtins::CALL_FUNCTION_PROXY); 2324 __ GetBuiltinEntry(rdx, Builtins::CALL_FUNCTION_PROXY);
(...skipping 11 matching lines...) Expand all
2313 __ Set(rbx, 0); 2336 __ Set(rbx, 0);
2314 __ GetBuiltinEntry(rdx, Builtins::CALL_NON_FUNCTION); 2337 __ GetBuiltinEntry(rdx, Builtins::CALL_NON_FUNCTION);
2315 Handle<Code> adaptor = 2338 Handle<Code> adaptor =
2316 isolate->builtins()->ArgumentsAdaptorTrampoline(); 2339 isolate->builtins()->ArgumentsAdaptorTrampoline();
2317 __ Jump(adaptor, RelocInfo::CODE_TARGET); 2340 __ Jump(adaptor, RelocInfo::CODE_TARGET);
2318 } 2341 }
2319 2342
2320 2343
2321 void CallConstructStub::Generate(MacroAssembler* masm) { 2344 void CallConstructStub::Generate(MacroAssembler* masm) {
2322 // rax : number of arguments 2345 // rax : number of arguments
2323 // rbx : cache cell for call target 2346 // rbx : feedback vector
2347 // rdx : (only if rbx is not undefined) slot in feedback vector (Smi)
2324 // rdi : constructor function 2348 // rdi : constructor function
2325 Label slow, non_function_call; 2349 Label slow, non_function_call;
2326 2350
2327 // Check that function is not a smi. 2351 // Check that function is not a smi.
2328 __ JumpIfSmi(rdi, &non_function_call); 2352 __ JumpIfSmi(rdi, &non_function_call);
2329 // Check that function is a JSFunction. 2353 // Check that function is a JSFunction.
2330 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx); 2354 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx);
2331 __ j(not_equal, &slow); 2355 __ j(not_equal, &slow);
2332 2356
2333 if (RecordCallTarget()) { 2357 if (RecordCallTarget()) {
(...skipping 2620 matching lines...) Expand 10 before | Expand all | Expand 10 after
4954 CreateArrayDispatch<ArrayNArgumentsConstructorStub>(masm, mode); 4978 CreateArrayDispatch<ArrayNArgumentsConstructorStub>(masm, mode);
4955 } else { 4979 } else {
4956 UNREACHABLE(); 4980 UNREACHABLE();
4957 } 4981 }
4958 } 4982 }
4959 4983
4960 4984
4961 void ArrayConstructorStub::Generate(MacroAssembler* masm) { 4985 void ArrayConstructorStub::Generate(MacroAssembler* masm) {
4962 // ----------- S t a t e ------------- 4986 // ----------- S t a t e -------------
4963 // -- rax : argc 4987 // -- rax : argc
4964 // -- rbx : type info cell 4988 // -- rbx : feedback vector (fixed array or undefined)
4989 // -- rdx : slot index (if ebx is fixed array)
4965 // -- rdi : constructor 4990 // -- rdi : constructor
4966 // -- rsp[0] : return address 4991 // -- rsp[0] : return address
4967 // -- rsp[8] : last argument 4992 // -- rsp[8] : last argument
4968 // ----------------------------------- 4993 // -----------------------------------
4969 Handle<Object> undefined_sentinel( 4994 Handle<Object> undefined_sentinel(
4970 masm->isolate()->heap()->undefined_value(), 4995 masm->isolate()->heap()->undefined_value(),
4971 masm->isolate()); 4996 masm->isolate());
4972 4997
4973 if (FLAG_debug_code) { 4998 if (FLAG_debug_code) {
4974 // The array construct code is only set for the global and natives 4999 // The array construct code is only set for the global and natives
4975 // builtin Array functions which always have maps. 5000 // builtin Array functions which always have maps.
4976 5001
4977 // Initial map for the builtin Array function should be a map. 5002 // Initial map for the builtin Array function should be a map.
4978 __ movp(rcx, FieldOperand(rdi, JSFunction::kPrototypeOrInitialMapOffset)); 5003 __ movp(rcx, FieldOperand(rdi, JSFunction::kPrototypeOrInitialMapOffset));
4979 // Will both indicate a NULL and a Smi. 5004 // Will both indicate a NULL and a Smi.
4980 STATIC_ASSERT(kSmiTag == 0); 5005 STATIC_ASSERT(kSmiTag == 0);
4981 Condition not_smi = NegateCondition(masm->CheckSmi(rcx)); 5006 Condition not_smi = NegateCondition(masm->CheckSmi(rcx));
4982 __ Check(not_smi, kUnexpectedInitialMapForArrayFunction); 5007 __ Check(not_smi, kUnexpectedInitialMapForArrayFunction);
4983 __ CmpObjectType(rcx, MAP_TYPE, rcx); 5008 __ CmpObjectType(rcx, MAP_TYPE, rcx);
4984 __ Check(equal, kUnexpectedInitialMapForArrayFunction); 5009 __ Check(equal, kUnexpectedInitialMapForArrayFunction);
4985 5010
4986 // We should either have undefined in rbx or a valid cell 5011 // We should either have undefined in rbx or a valid cell
4987 Label okay_here; 5012 Label okay_here;
4988 Handle<Map> cell_map = masm->isolate()->factory()->cell_map(); 5013 Handle<Map> fixed_array_map = masm->isolate()->factory()->fixed_array_map();
4989 __ Cmp(rbx, undefined_sentinel); 5014 __ Cmp(rbx, undefined_sentinel);
4990 __ j(equal, &okay_here); 5015 __ j(equal, &okay_here);
4991 __ Cmp(FieldOperand(rbx, 0), cell_map); 5016 __ Cmp(FieldOperand(rbx, 0), fixed_array_map);
4992 __ Assert(equal, kExpectedPropertyCellInRegisterRbx); 5017 __ Assert(equal, kExpectedFixedArrayInRegisterRbx);
5018
5019 // rdx should be a smi if we don't have undefined in rbx.
5020 __ AssertSmi(rdx);
5021
4993 __ bind(&okay_here); 5022 __ bind(&okay_here);
4994 } 5023 }
4995 5024
4996 Label no_info; 5025 Label no_info;
4997 // If the type cell is undefined, or contains anything other than an 5026 // If the type cell is undefined, or contains anything other than an
4998 // AllocationSite, call an array constructor that doesn't use AllocationSites. 5027 // AllocationSite, call an array constructor that doesn't use AllocationSites.
4999 __ Cmp(rbx, undefined_sentinel); 5028 __ Cmp(rbx, undefined_sentinel);
5000 __ j(equal, &no_info); 5029 __ j(equal, &no_info);
5001 __ movp(rbx, FieldOperand(rbx, Cell::kValueOffset)); 5030 __ SmiToInteger32(rdx, rdx);
5031 __ movp(rbx, FieldOperand(rbx, rdx, times_pointer_size,
5032 FixedArray::kHeaderSize));
5033 __ Integer32ToSmi(rdx, rdx);
5002 __ Cmp(FieldOperand(rbx, 0), 5034 __ Cmp(FieldOperand(rbx, 0),
5003 masm->isolate()->factory()->allocation_site_map()); 5035 masm->isolate()->factory()->allocation_site_map());
5004 __ j(not_equal, &no_info); 5036 __ j(not_equal, &no_info);
5005 5037
5006 // Only look at the lower 16 bits of the transition info. 5038 // Only look at the lower 16 bits of the transition info.
5007 __ movp(rdx, FieldOperand(rbx, AllocationSite::kTransitionInfoOffset)); 5039 __ movp(rdx, FieldOperand(rbx, AllocationSite::kTransitionInfoOffset));
5008 __ SmiToInteger32(rdx, rdx); 5040 __ SmiToInteger32(rdx, rdx);
5009 STATIC_ASSERT(AllocationSite::ElementsKindBits::kShift == 0); 5041 STATIC_ASSERT(AllocationSite::ElementsKindBits::kShift == 0);
5010 __ and_(rdx, Immediate(AllocationSite::ElementsKindBits::kMask)); 5042 __ and_(rdx, Immediate(AllocationSite::ElementsKindBits::kMask));
5011 GenerateDispatchToArrayStub(masm, DONT_OVERRIDE); 5043 GenerateDispatchToArrayStub(masm, DONT_OVERRIDE);
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
5278 return_value_operand, 5310 return_value_operand,
5279 NULL); 5311 NULL);
5280 } 5312 }
5281 5313
5282 5314
5283 #undef __ 5315 #undef __
5284 5316
5285 } } // namespace v8::internal 5317 } } // namespace v8::internal
5286 5318
5287 #endif // V8_TARGET_ARCH_X64 5319 #endif // V8_TARGET_ARCH_X64
OLDNEW
« src/type-info.cc ('K') | « src/typing.cc ('k') | src/x64/debug-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698