OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 } | 178 } |
179 | 179 |
180 | 180 |
181 void StubCache::GenerateProbe(MacroAssembler* masm, | 181 void StubCache::GenerateProbe(MacroAssembler* masm, |
182 Code::Flags flags, | 182 Code::Flags flags, |
183 Register receiver, | 183 Register receiver, |
184 Register name, | 184 Register name, |
185 Register scratch, | 185 Register scratch, |
186 Register extra, | 186 Register extra, |
187 Register extra2) { | 187 Register extra2) { |
188 Isolate* isolate = Isolate::Current(); | 188 Isolate* isolate = masm->isolate(); |
189 Label miss; | 189 Label miss; |
190 USE(extra); // The register extra is not used on the X64 platform. | 190 USE(extra); // The register extra is not used on the X64 platform. |
191 USE(extra2); // The register extra2 is not used on the X64 platform. | 191 USE(extra2); // The register extra2 is not used on the X64 platform. |
192 // Make sure that code is valid. The shifting code relies on the | 192 // Make sure that code is valid. The shifting code relies on the |
193 // entry size being 16. | 193 // entry size being 16. |
194 ASSERT(sizeof(Entry) == 16); | 194 ASSERT(sizeof(Entry) == 16); |
195 | 195 |
196 // Make sure the flags do not name a specific type. | 196 // Make sure the flags do not name a specific type. |
197 ASSERT(Code::ExtractTypeFromFlags(flags) == 0); | 197 ASSERT(Code::ExtractTypeFromFlags(flags) == 0); |
198 | 198 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 // Load the initial map. The global functions all have initial maps. | 249 // Load the initial map. The global functions all have initial maps. |
250 __ movq(prototype, | 250 __ movq(prototype, |
251 FieldOperand(prototype, JSFunction::kPrototypeOrInitialMapOffset)); | 251 FieldOperand(prototype, JSFunction::kPrototypeOrInitialMapOffset)); |
252 // Load the prototype from the initial map. | 252 // Load the prototype from the initial map. |
253 __ movq(prototype, FieldOperand(prototype, Map::kPrototypeOffset)); | 253 __ movq(prototype, FieldOperand(prototype, Map::kPrototypeOffset)); |
254 } | 254 } |
255 | 255 |
256 | 256 |
257 void StubCompiler::GenerateDirectLoadGlobalFunctionPrototype( | 257 void StubCompiler::GenerateDirectLoadGlobalFunctionPrototype( |
258 MacroAssembler* masm, int index, Register prototype, Label* miss) { | 258 MacroAssembler* masm, int index, Register prototype, Label* miss) { |
| 259 Isolate* isolate = masm->isolate(); |
259 // Check we're still in the same context. | 260 // Check we're still in the same context. |
260 __ Move(prototype, Isolate::Current()->global()); | 261 __ Move(prototype, isolate->global()); |
261 __ cmpq(Operand(rsi, Context::SlotOffset(Context::GLOBAL_INDEX)), | 262 __ cmpq(Operand(rsi, Context::SlotOffset(Context::GLOBAL_INDEX)), |
262 prototype); | 263 prototype); |
263 __ j(not_equal, miss); | 264 __ j(not_equal, miss); |
264 // Get the global function with the given index. | 265 // Get the global function with the given index. |
265 JSFunction* function = JSFunction::cast( | 266 JSFunction* function = |
266 Isolate::Current()->global_context()->get(index)); | 267 JSFunction::cast(isolate->global_context()->get(index)); |
267 // Load its initial map. The global functions all have initial maps. | 268 // Load its initial map. The global functions all have initial maps. |
268 __ Move(prototype, Handle<Map>(function->initial_map())); | 269 __ Move(prototype, Handle<Map>(function->initial_map())); |
269 // Load the prototype from the initial map. | 270 // Load the prototype from the initial map. |
270 __ movq(prototype, FieldOperand(prototype, Map::kPrototypeOffset)); | 271 __ movq(prototype, FieldOperand(prototype, Map::kPrototypeOffset)); |
271 } | 272 } |
272 | 273 |
273 | 274 |
274 void StubCompiler::GenerateLoadArrayLength(MacroAssembler* masm, | 275 void StubCompiler::GenerateLoadArrayLength(MacroAssembler* masm, |
275 Register receiver, | 276 Register receiver, |
276 Register scratch, | 277 Register scratch, |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 StubCompiler* stub_compiler_; | 730 StubCompiler* stub_compiler_; |
730 const ParameterCount& arguments_; | 731 const ParameterCount& arguments_; |
731 Register name_; | 732 Register name_; |
732 }; | 733 }; |
733 | 734 |
734 | 735 |
735 void StubCompiler::GenerateLoadMiss(MacroAssembler* masm, Code::Kind kind) { | 736 void StubCompiler::GenerateLoadMiss(MacroAssembler* masm, Code::Kind kind) { |
736 ASSERT(kind == Code::LOAD_IC || kind == Code::KEYED_LOAD_IC); | 737 ASSERT(kind == Code::LOAD_IC || kind == Code::KEYED_LOAD_IC); |
737 Code* code = NULL; | 738 Code* code = NULL; |
738 if (kind == Code::LOAD_IC) { | 739 if (kind == Code::LOAD_IC) { |
739 code = Isolate::Current()->builtins()->builtin(Builtins::LoadIC_Miss); | 740 code = masm->isolate()->builtins()->builtin(Builtins::kLoadIC_Miss); |
740 } else { | 741 } else { |
741 code = Isolate::Current()->builtins()->builtin(Builtins::KeyedLoadIC_Miss); | 742 code = masm->isolate()->builtins()->builtin(Builtins::kKeyedLoadIC_Miss); |
742 } | 743 } |
743 | 744 |
744 Handle<Code> ic(code); | 745 Handle<Code> ic(code); |
745 __ Jump(ic, RelocInfo::CODE_TARGET); | 746 __ Jump(ic, RelocInfo::CODE_TARGET); |
746 } | 747 } |
747 | 748 |
748 | 749 |
749 // Both name_reg and receiver_reg are preserved on jumps to miss_label, | 750 // Both name_reg and receiver_reg are preserved on jumps to miss_label, |
750 // but may be destroyed if store is successful. | 751 // but may be destroyed if store is successful. |
751 void StubCompiler::GenerateStoreField(MacroAssembler* masm, | 752 void StubCompiler::GenerateStoreField(MacroAssembler* masm, |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1317 __ cmpq(FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset), rax); | 1318 __ cmpq(FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset), rax); |
1318 __ j(not_equal, miss); | 1319 __ j(not_equal, miss); |
1319 } else { | 1320 } else { |
1320 __ Cmp(rdi, Handle<JSFunction>(function)); | 1321 __ Cmp(rdi, Handle<JSFunction>(function)); |
1321 __ j(not_equal, miss); | 1322 __ j(not_equal, miss); |
1322 } | 1323 } |
1323 } | 1324 } |
1324 | 1325 |
1325 | 1326 |
1326 MaybeObject* CallStubCompiler::GenerateMissBranch() { | 1327 MaybeObject* CallStubCompiler::GenerateMissBranch() { |
1327 MaybeObject* maybe_obj = Isolate::Current()->stub_cache()->ComputeCallMiss( | 1328 MaybeObject* maybe_obj = masm()->isolate()->stub_cache()->ComputeCallMiss( |
1328 arguments().immediate(), kind_); | 1329 arguments().immediate(), kind_); |
1329 Object* obj; | 1330 Object* obj; |
1330 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 1331 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
1331 __ Jump(Handle<Code>(Code::cast(obj)), RelocInfo::CODE_TARGET); | 1332 __ Jump(Handle<Code>(Code::cast(obj)), RelocInfo::CODE_TARGET); |
1332 return obj; | 1333 return obj; |
1333 } | 1334 } |
1334 | 1335 |
1335 | 1336 |
1336 MaybeObject* CallStubCompiler::CompileCallField(JSObject* object, | 1337 MaybeObject* CallStubCompiler::CompileCallField(JSObject* object, |
1337 JSObject* holder, | 1338 JSObject* holder, |
(...skipping 989 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2327 // Generate store field code. Preserves receiver and name on jump to miss. | 2328 // Generate store field code. Preserves receiver and name on jump to miss. |
2328 GenerateStoreField(masm(), | 2329 GenerateStoreField(masm(), |
2329 object, | 2330 object, |
2330 index, | 2331 index, |
2331 transition, | 2332 transition, |
2332 rdx, rcx, rbx, | 2333 rdx, rcx, rbx, |
2333 &miss); | 2334 &miss); |
2334 | 2335 |
2335 // Handle store cache miss. | 2336 // Handle store cache miss. |
2336 __ bind(&miss); | 2337 __ bind(&miss); |
2337 Handle<Code> ic(Isolate::Current()->builtins()->builtin( | 2338 Handle<Code> ic = masm()->isolate()->builtins()->StoreIC_Miss(); |
2338 Builtins::StoreIC_Miss)); | |
2339 __ Jump(ic, RelocInfo::CODE_TARGET); | 2339 __ Jump(ic, RelocInfo::CODE_TARGET); |
2340 | 2340 |
2341 // Return the generated code. | 2341 // Return the generated code. |
2342 return GetCode(transition == NULL ? FIELD : MAP_TRANSITION, name); | 2342 return GetCode(transition == NULL ? FIELD : MAP_TRANSITION, name); |
2343 } | 2343 } |
2344 | 2344 |
2345 | 2345 |
2346 MaybeObject* StoreStubCompiler::CompileStoreCallback(JSObject* object, | 2346 MaybeObject* StoreStubCompiler::CompileStoreCallback(JSObject* object, |
2347 AccessorInfo* callback, | 2347 AccessorInfo* callback, |
2348 String* name) { | 2348 String* name) { |
(...skipping 30 matching lines...) Expand all Loading... |
2379 __ push(rbx); // restore return address | 2379 __ push(rbx); // restore return address |
2380 | 2380 |
2381 // Do tail-call to the runtime system. | 2381 // Do tail-call to the runtime system. |
2382 ExternalReference store_callback_property = | 2382 ExternalReference store_callback_property = |
2383 ExternalReference(IC_Utility(IC::kStoreCallbackProperty), | 2383 ExternalReference(IC_Utility(IC::kStoreCallbackProperty), |
2384 masm()->isolate()); | 2384 masm()->isolate()); |
2385 __ TailCallExternalReference(store_callback_property, 4, 1); | 2385 __ TailCallExternalReference(store_callback_property, 4, 1); |
2386 | 2386 |
2387 // Handle store cache miss. | 2387 // Handle store cache miss. |
2388 __ bind(&miss); | 2388 __ bind(&miss); |
2389 Handle<Code> ic(Isolate::Current()->builtins()->builtin( | 2389 Handle<Code> ic = masm()->isolate()->builtins()->StoreIC_Miss(); |
2390 Builtins::StoreIC_Miss)); | |
2391 __ Jump(ic, RelocInfo::CODE_TARGET); | 2390 __ Jump(ic, RelocInfo::CODE_TARGET); |
2392 | 2391 |
2393 // Return the generated code. | 2392 // Return the generated code. |
2394 return GetCode(CALLBACKS, name); | 2393 return GetCode(CALLBACKS, name); |
2395 } | 2394 } |
2396 | 2395 |
2397 | 2396 |
2398 MaybeObject* StoreStubCompiler::CompileStoreInterceptor(JSObject* receiver, | 2397 MaybeObject* StoreStubCompiler::CompileStoreInterceptor(JSObject* receiver, |
2399 String* name) { | 2398 String* name) { |
2400 // ----------- S t a t e ------------- | 2399 // ----------- S t a t e ------------- |
(...skipping 29 matching lines...) Expand all Loading... |
2430 __ push(rbx); // restore return address | 2429 __ push(rbx); // restore return address |
2431 | 2430 |
2432 // Do tail-call to the runtime system. | 2431 // Do tail-call to the runtime system. |
2433 ExternalReference store_ic_property = | 2432 ExternalReference store_ic_property = |
2434 ExternalReference(IC_Utility(IC::kStoreInterceptorProperty), | 2433 ExternalReference(IC_Utility(IC::kStoreInterceptorProperty), |
2435 masm()->isolate()); | 2434 masm()->isolate()); |
2436 __ TailCallExternalReference(store_ic_property, 4, 1); | 2435 __ TailCallExternalReference(store_ic_property, 4, 1); |
2437 | 2436 |
2438 // Handle store cache miss. | 2437 // Handle store cache miss. |
2439 __ bind(&miss); | 2438 __ bind(&miss); |
2440 Handle<Code> ic(Isolate::Current()->builtins()->builtin( | 2439 Handle<Code> ic = masm()->isolate()->builtins()->StoreIC_Miss(); |
2441 Builtins::StoreIC_Miss)); | |
2442 __ Jump(ic, RelocInfo::CODE_TARGET); | 2440 __ Jump(ic, RelocInfo::CODE_TARGET); |
2443 | 2441 |
2444 // Return the generated code. | 2442 // Return the generated code. |
2445 return GetCode(INTERCEPTOR, name); | 2443 return GetCode(INTERCEPTOR, name); |
2446 } | 2444 } |
2447 | 2445 |
2448 | 2446 |
2449 MaybeObject* StoreStubCompiler::CompileStoreGlobal(GlobalObject* object, | 2447 MaybeObject* StoreStubCompiler::CompileStoreGlobal(GlobalObject* object, |
2450 JSGlobalPropertyCell* cell, | 2448 JSGlobalPropertyCell* cell, |
2451 String* name) { | 2449 String* name) { |
(...skipping 23 matching lines...) Expand all Loading... |
2475 __ movq(FieldOperand(rbx, JSGlobalPropertyCell::kValueOffset), rax); | 2473 __ movq(FieldOperand(rbx, JSGlobalPropertyCell::kValueOffset), rax); |
2476 | 2474 |
2477 // Return the value (register rax). | 2475 // Return the value (register rax). |
2478 Counters* counters = masm()->isolate()->counters(); | 2476 Counters* counters = masm()->isolate()->counters(); |
2479 __ IncrementCounter(counters->named_store_global_inline(), 1); | 2477 __ IncrementCounter(counters->named_store_global_inline(), 1); |
2480 __ ret(0); | 2478 __ ret(0); |
2481 | 2479 |
2482 // Handle store cache miss. | 2480 // Handle store cache miss. |
2483 __ bind(&miss); | 2481 __ bind(&miss); |
2484 __ IncrementCounter(counters->named_store_global_inline_miss(), 1); | 2482 __ IncrementCounter(counters->named_store_global_inline_miss(), 1); |
2485 Handle<Code> ic(Isolate::Current()->builtins()->builtin( | 2483 Handle<Code> ic = masm()->isolate()->builtins()->StoreIC_Miss(); |
2486 Builtins::StoreIC_Miss)); | |
2487 __ Jump(ic, RelocInfo::CODE_TARGET); | 2484 __ Jump(ic, RelocInfo::CODE_TARGET); |
2488 | 2485 |
2489 // Return the generated code. | 2486 // Return the generated code. |
2490 return GetCode(NORMAL, name); | 2487 return GetCode(NORMAL, name); |
2491 } | 2488 } |
2492 | 2489 |
2493 | 2490 |
2494 MaybeObject* KeyedStoreStubCompiler::CompileStoreField(JSObject* object, | 2491 MaybeObject* KeyedStoreStubCompiler::CompileStoreField(JSObject* object, |
2495 int index, | 2492 int index, |
2496 Map* transition, | 2493 Map* transition, |
(...skipping 17 matching lines...) Expand all Loading... |
2514 GenerateStoreField(masm(), | 2511 GenerateStoreField(masm(), |
2515 object, | 2512 object, |
2516 index, | 2513 index, |
2517 transition, | 2514 transition, |
2518 rdx, rcx, rbx, | 2515 rdx, rcx, rbx, |
2519 &miss); | 2516 &miss); |
2520 | 2517 |
2521 // Handle store cache miss. | 2518 // Handle store cache miss. |
2522 __ bind(&miss); | 2519 __ bind(&miss); |
2523 __ DecrementCounter(counters->keyed_store_field(), 1); | 2520 __ DecrementCounter(counters->keyed_store_field(), 1); |
2524 Handle<Code> ic(Isolate::Current()->builtins()->builtin( | 2521 Handle<Code> ic = masm()->isolate()->builtins()->KeyedStoreIC_Miss(); |
2525 Builtins::KeyedStoreIC_Miss)); | |
2526 __ Jump(ic, RelocInfo::CODE_TARGET); | 2522 __ Jump(ic, RelocInfo::CODE_TARGET); |
2527 | 2523 |
2528 // Return the generated code. | 2524 // Return the generated code. |
2529 return GetCode(transition == NULL ? FIELD : MAP_TRANSITION, name); | 2525 return GetCode(transition == NULL ? FIELD : MAP_TRANSITION, name); |
2530 } | 2526 } |
2531 | 2527 |
2532 | 2528 |
2533 MaybeObject* KeyedStoreStubCompiler::CompileStoreSpecialized( | 2529 MaybeObject* KeyedStoreStubCompiler::CompileStoreSpecialized( |
2534 JSObject* receiver) { | 2530 JSObject* receiver) { |
2535 // ----------- S t a t e ------------- | 2531 // ----------- S t a t e ------------- |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2572 __ SmiToInteger32(rcx, rcx); | 2568 __ SmiToInteger32(rcx, rcx); |
2573 __ movq(FieldOperand(rdi, rcx, times_pointer_size, FixedArray::kHeaderSize), | 2569 __ movq(FieldOperand(rdi, rcx, times_pointer_size, FixedArray::kHeaderSize), |
2574 rax); | 2570 rax); |
2575 __ RecordWrite(rdi, 0, rdx, rcx); | 2571 __ RecordWrite(rdi, 0, rdx, rcx); |
2576 | 2572 |
2577 // Done. | 2573 // Done. |
2578 __ ret(0); | 2574 __ ret(0); |
2579 | 2575 |
2580 // Handle store cache miss. | 2576 // Handle store cache miss. |
2581 __ bind(&miss); | 2577 __ bind(&miss); |
2582 Handle<Code> ic(Isolate::Current()->builtins()->builtin( | 2578 Handle<Code> ic = masm()->isolate()->builtins()->KeyedStoreIC_Miss(); |
2583 Builtins::KeyedStoreIC_Miss)); | |
2584 __ jmp(ic, RelocInfo::CODE_TARGET); | 2579 __ jmp(ic, RelocInfo::CODE_TARGET); |
2585 | 2580 |
2586 // Return the generated code. | 2581 // Return the generated code. |
2587 return GetCode(NORMAL, NULL); | 2582 return GetCode(NORMAL, NULL); |
2588 } | 2583 } |
2589 | 2584 |
2590 | 2585 |
2591 MaybeObject* LoadStubCompiler::CompileLoadNonexistent(String* name, | 2586 MaybeObject* LoadStubCompiler::CompileLoadNonexistent(String* name, |
2592 JSObject* object, | 2587 JSObject* object, |
2593 JSObject* last) { | 2588 JSObject* last) { |
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3151 __ lea(rsp, Operand(rsp, rbx, times_pointer_size, 1 * kPointerSize)); | 3146 __ lea(rsp, Operand(rsp, rbx, times_pointer_size, 1 * kPointerSize)); |
3152 __ push(rcx); | 3147 __ push(rcx); |
3153 Counters* counters = masm()->isolate()->counters(); | 3148 Counters* counters = masm()->isolate()->counters(); |
3154 __ IncrementCounter(counters->constructed_objects(), 1); | 3149 __ IncrementCounter(counters->constructed_objects(), 1); |
3155 __ IncrementCounter(counters->constructed_objects_stub(), 1); | 3150 __ IncrementCounter(counters->constructed_objects_stub(), 1); |
3156 __ ret(0); | 3151 __ ret(0); |
3157 | 3152 |
3158 // Jump to the generic stub in case the specialized code cannot handle the | 3153 // Jump to the generic stub in case the specialized code cannot handle the |
3159 // construction. | 3154 // construction. |
3160 __ bind(&generic_stub_call); | 3155 __ bind(&generic_stub_call); |
3161 Code* code = Isolate::Current()->builtins()->builtin( | 3156 Code* code = |
3162 Builtins::JSConstructStubGeneric); | 3157 masm()->isolate()->builtins()->builtin(Builtins::kJSConstructStubGeneric); |
3163 Handle<Code> generic_construct_stub(code); | 3158 Handle<Code> generic_construct_stub(code); |
3164 __ Jump(generic_construct_stub, RelocInfo::CODE_TARGET); | 3159 __ Jump(generic_construct_stub, RelocInfo::CODE_TARGET); |
3165 | 3160 |
3166 // Return the generated code. | 3161 // Return the generated code. |
3167 return GetCode(); | 3162 return GetCode(); |
3168 } | 3163 } |
3169 | 3164 |
3170 | 3165 |
3171 MaybeObject* ExternalArrayStubCompiler::CompileKeyedLoadStub( | 3166 MaybeObject* ExternalArrayStubCompiler::CompileKeyedLoadStub( |
3172 JSObject* receiver, ExternalArrayType array_type, Code::Flags flags) { | 3167 JSObject* receiver, ExternalArrayType array_type, Code::Flags flags) { |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3459 __ TailCallRuntime(Runtime::kSetProperty, 5, 1); | 3454 __ TailCallRuntime(Runtime::kSetProperty, 5, 1); |
3460 | 3455 |
3461 return GetCode(flags); | 3456 return GetCode(flags); |
3462 } | 3457 } |
3463 | 3458 |
3464 #undef __ | 3459 #undef __ |
3465 | 3460 |
3466 } } // namespace v8::internal | 3461 } } // namespace v8::internal |
3467 | 3462 |
3468 #endif // V8_TARGET_ARCH_X64 | 3463 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |