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

Side by Side Diff: src/x64/stub-cache-x64.cc

Issue 6717018: Introduce accessors on builtins instance (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 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
« src/builtins.cc ('K') | « src/x64/macro-assembler-x64.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 } 177 }
178 178
179 179
180 void StubCache::GenerateProbe(MacroAssembler* masm, 180 void StubCache::GenerateProbe(MacroAssembler* masm,
181 Code::Flags flags, 181 Code::Flags flags,
182 Register receiver, 182 Register receiver,
183 Register name, 183 Register name,
184 Register scratch, 184 Register scratch,
185 Register extra, 185 Register extra,
186 Register extra2) { 186 Register extra2) {
187 Isolate* isolate = Isolate::Current(); 187 Isolate* isolate = masm->isolate();
188 Label miss; 188 Label miss;
189 USE(extra); // The register extra is not used on the X64 platform. 189 USE(extra); // The register extra is not used on the X64 platform.
190 USE(extra2); // The register extra2 is not used on the X64 platform. 190 USE(extra2); // The register extra2 is not used on the X64 platform.
191 // Make sure that code is valid. The shifting code relies on the 191 // Make sure that code is valid. The shifting code relies on the
192 // entry size being 16. 192 // entry size being 16.
193 ASSERT(sizeof(Entry) == 16); 193 ASSERT(sizeof(Entry) == 16);
194 194
195 // Make sure the flags do not name a specific type. 195 // Make sure the flags do not name a specific type.
196 ASSERT(Code::ExtractTypeFromFlags(flags) == 0); 196 ASSERT(Code::ExtractTypeFromFlags(flags) == 0);
197 197
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 // Load the initial map. The global functions all have initial maps. 248 // Load the initial map. The global functions all have initial maps.
249 __ movq(prototype, 249 __ movq(prototype,
250 FieldOperand(prototype, JSFunction::kPrototypeOrInitialMapOffset)); 250 FieldOperand(prototype, JSFunction::kPrototypeOrInitialMapOffset));
251 // Load the prototype from the initial map. 251 // Load the prototype from the initial map.
252 __ movq(prototype, FieldOperand(prototype, Map::kPrototypeOffset)); 252 __ movq(prototype, FieldOperand(prototype, Map::kPrototypeOffset));
253 } 253 }
254 254
255 255
256 void StubCompiler::GenerateDirectLoadGlobalFunctionPrototype( 256 void StubCompiler::GenerateDirectLoadGlobalFunctionPrototype(
257 MacroAssembler* masm, int index, Register prototype, Label* miss) { 257 MacroAssembler* masm, int index, Register prototype, Label* miss) {
258 Isolate* isolate = masm->isolate();
258 // Check we're still in the same context. 259 // Check we're still in the same context.
259 __ Move(prototype, Isolate::Current()->global()); 260 __ Move(prototype, isolate->global());
260 __ cmpq(Operand(rsi, Context::SlotOffset(Context::GLOBAL_INDEX)), 261 __ cmpq(Operand(rsi, Context::SlotOffset(Context::GLOBAL_INDEX)),
261 prototype); 262 prototype);
262 __ j(not_equal, miss); 263 __ j(not_equal, miss);
263 // Get the global function with the given index. 264 // Get the global function with the given index.
264 JSFunction* function = JSFunction::cast( 265 JSFunction* function =
265 Isolate::Current()->global_context()->get(index)); 266 JSFunction::cast(isolate->global_context()->get(index));
266 // Load its initial map. The global functions all have initial maps. 267 // Load its initial map. The global functions all have initial maps.
267 __ Move(prototype, Handle<Map>(function->initial_map())); 268 __ Move(prototype, Handle<Map>(function->initial_map()));
268 // Load the prototype from the initial map. 269 // Load the prototype from the initial map.
269 __ movq(prototype, FieldOperand(prototype, Map::kPrototypeOffset)); 270 __ movq(prototype, FieldOperand(prototype, Map::kPrototypeOffset));
270 } 271 }
271 272
272 273
273 void StubCompiler::GenerateLoadArrayLength(MacroAssembler* masm, 274 void StubCompiler::GenerateLoadArrayLength(MacroAssembler* masm,
274 Register receiver, 275 Register receiver,
275 Register scratch, 276 Register scratch,
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 StubCompiler* stub_compiler_; 728 StubCompiler* stub_compiler_;
728 const ParameterCount& arguments_; 729 const ParameterCount& arguments_;
729 Register name_; 730 Register name_;
730 }; 731 };
731 732
732 733
733 void StubCompiler::GenerateLoadMiss(MacroAssembler* masm, Code::Kind kind) { 734 void StubCompiler::GenerateLoadMiss(MacroAssembler* masm, Code::Kind kind) {
734 ASSERT(kind == Code::LOAD_IC || kind == Code::KEYED_LOAD_IC); 735 ASSERT(kind == Code::LOAD_IC || kind == Code::KEYED_LOAD_IC);
735 Code* code = NULL; 736 Code* code = NULL;
736 if (kind == Code::LOAD_IC) { 737 if (kind == Code::LOAD_IC) {
737 code = Isolate::Current()->builtins()->builtin(Builtins::LoadIC_Miss); 738 code = masm->isolate()->builtins()->builtin(Builtins::LoadIC_Miss);
738 } else { 739 } else {
739 code = Isolate::Current()->builtins()->builtin(Builtins::KeyedLoadIC_Miss); 740 code = masm->isolate()->builtins()->builtin(Builtins::KeyedLoadIC_Miss);
740 } 741 }
741 742
742 Handle<Code> ic(code); 743 Handle<Code> ic(code);
743 __ Jump(ic, RelocInfo::CODE_TARGET); 744 __ Jump(ic, RelocInfo::CODE_TARGET);
744 } 745 }
745 746
746 747
747 // Both name_reg and receiver_reg are preserved on jumps to miss_label, 748 // Both name_reg and receiver_reg are preserved on jumps to miss_label,
748 // but may be destroyed if store is successful. 749 // but may be destroyed if store is successful.
749 void StubCompiler::GenerateStoreField(MacroAssembler* masm, 750 void StubCompiler::GenerateStoreField(MacroAssembler* masm,
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
1315 __ cmpq(FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset), rax); 1316 __ cmpq(FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset), rax);
1316 __ j(not_equal, miss); 1317 __ j(not_equal, miss);
1317 } else { 1318 } else {
1318 __ Cmp(rdi, Handle<JSFunction>(function)); 1319 __ Cmp(rdi, Handle<JSFunction>(function));
1319 __ j(not_equal, miss); 1320 __ j(not_equal, miss);
1320 } 1321 }
1321 } 1322 }
1322 1323
1323 1324
1324 MaybeObject* CallStubCompiler::GenerateMissBranch() { 1325 MaybeObject* CallStubCompiler::GenerateMissBranch() {
1325 MaybeObject* maybe_obj = Isolate::Current()->stub_cache()->ComputeCallMiss( 1326 MaybeObject* maybe_obj = masm()->isolate()->stub_cache()->ComputeCallMiss(
1326 arguments().immediate(), kind_); 1327 arguments().immediate(), kind_);
1327 Object* obj; 1328 Object* obj;
1328 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 1329 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
1329 __ Jump(Handle<Code>(Code::cast(obj)), RelocInfo::CODE_TARGET); 1330 __ Jump(Handle<Code>(Code::cast(obj)), RelocInfo::CODE_TARGET);
1330 return obj; 1331 return obj;
1331 } 1332 }
1332 1333
1333 1334
1334 MaybeObject* CallStubCompiler::CompileCallField(JSObject* object, 1335 MaybeObject* CallStubCompiler::CompileCallField(JSObject* object,
1335 JSObject* holder, 1336 JSObject* holder,
(...skipping 987 matching lines...) Expand 10 before | Expand all | Expand 10 after
2323 // Generate store field code. Preserves receiver and name on jump to miss. 2324 // Generate store field code. Preserves receiver and name on jump to miss.
2324 GenerateStoreField(masm(), 2325 GenerateStoreField(masm(),
2325 object, 2326 object,
2326 index, 2327 index,
2327 transition, 2328 transition,
2328 rdx, rcx, rbx, 2329 rdx, rcx, rbx,
2329 &miss); 2330 &miss);
2330 2331
2331 // Handle store cache miss. 2332 // Handle store cache miss.
2332 __ bind(&miss); 2333 __ bind(&miss);
2333 Handle<Code> ic(Isolate::Current()->builtins()->builtin( 2334 Handle<Code> ic =
2334 Builtins::StoreIC_Miss)); 2335 Builtins::builtin(Builtins::StoreIC_Miss, masm()->isolate());
2335 __ Jump(ic, RelocInfo::CODE_TARGET); 2336 __ Jump(ic, RelocInfo::CODE_TARGET);
2336 2337
2337 // Return the generated code. 2338 // Return the generated code.
2338 return GetCode(transition == NULL ? FIELD : MAP_TRANSITION, name); 2339 return GetCode(transition == NULL ? FIELD : MAP_TRANSITION, name);
2339 } 2340 }
2340 2341
2341 2342
2342 MaybeObject* StoreStubCompiler::CompileStoreCallback(JSObject* object, 2343 MaybeObject* StoreStubCompiler::CompileStoreCallback(JSObject* object,
2343 AccessorInfo* callback, 2344 AccessorInfo* callback,
2344 String* name) { 2345 String* name) {
(...skipping 30 matching lines...) Expand all
2375 __ push(rbx); // restore return address 2376 __ push(rbx); // restore return address
2376 2377
2377 // Do tail-call to the runtime system. 2378 // Do tail-call to the runtime system.
2378 ExternalReference store_callback_property = 2379 ExternalReference store_callback_property =
2379 ExternalReference(IC_Utility(IC::kStoreCallbackProperty), 2380 ExternalReference(IC_Utility(IC::kStoreCallbackProperty),
2380 masm()->isolate()); 2381 masm()->isolate());
2381 __ TailCallExternalReference(store_callback_property, 4, 1); 2382 __ TailCallExternalReference(store_callback_property, 4, 1);
2382 2383
2383 // Handle store cache miss. 2384 // Handle store cache miss.
2384 __ bind(&miss); 2385 __ bind(&miss);
2385 Handle<Code> ic(Isolate::Current()->builtins()->builtin( 2386 Handle<Code> ic =
2386 Builtins::StoreIC_Miss)); 2387 Builtins::builtin(Builtins::StoreIC_Miss, masm()->isolate());
2387 __ Jump(ic, RelocInfo::CODE_TARGET); 2388 __ Jump(ic, RelocInfo::CODE_TARGET);
2388 2389
2389 // Return the generated code. 2390 // Return the generated code.
2390 return GetCode(CALLBACKS, name); 2391 return GetCode(CALLBACKS, name);
2391 } 2392 }
2392 2393
2393 2394
2394 MaybeObject* StoreStubCompiler::CompileStoreInterceptor(JSObject* receiver, 2395 MaybeObject* StoreStubCompiler::CompileStoreInterceptor(JSObject* receiver,
2395 String* name) { 2396 String* name) {
2396 // ----------- S t a t e ------------- 2397 // ----------- S t a t e -------------
(...skipping 29 matching lines...) Expand all
2426 __ push(rbx); // restore return address 2427 __ push(rbx); // restore return address
2427 2428
2428 // Do tail-call to the runtime system. 2429 // Do tail-call to the runtime system.
2429 ExternalReference store_ic_property = 2430 ExternalReference store_ic_property =
2430 ExternalReference(IC_Utility(IC::kStoreInterceptorProperty), 2431 ExternalReference(IC_Utility(IC::kStoreInterceptorProperty),
2431 masm()->isolate()); 2432 masm()->isolate());
2432 __ TailCallExternalReference(store_ic_property, 4, 1); 2433 __ TailCallExternalReference(store_ic_property, 4, 1);
2433 2434
2434 // Handle store cache miss. 2435 // Handle store cache miss.
2435 __ bind(&miss); 2436 __ bind(&miss);
2436 Handle<Code> ic(Isolate::Current()->builtins()->builtin( 2437 Handle<Code> ic =
2437 Builtins::StoreIC_Miss)); 2438 Builtins::builtin(Builtins::StoreIC_Miss, masm()->isolate());
2438 __ Jump(ic, RelocInfo::CODE_TARGET); 2439 __ Jump(ic, RelocInfo::CODE_TARGET);
2439 2440
2440 // Return the generated code. 2441 // Return the generated code.
2441 return GetCode(INTERCEPTOR, name); 2442 return GetCode(INTERCEPTOR, name);
2442 } 2443 }
2443 2444
2444 2445
2445 MaybeObject* StoreStubCompiler::CompileStoreGlobal(GlobalObject* object, 2446 MaybeObject* StoreStubCompiler::CompileStoreGlobal(GlobalObject* object,
2446 JSGlobalPropertyCell* cell, 2447 JSGlobalPropertyCell* cell,
2447 String* name) { 2448 String* name) {
(...skipping 22 matching lines...) Expand all
2470 // Store the value in the cell. 2471 // Store the value in the cell.
2471 __ movq(FieldOperand(rbx, JSGlobalPropertyCell::kValueOffset), rax); 2472 __ movq(FieldOperand(rbx, JSGlobalPropertyCell::kValueOffset), rax);
2472 2473
2473 // Return the value (register rax). 2474 // Return the value (register rax).
2474 __ IncrementCounter(COUNTERS->named_store_global_inline(), 1); 2475 __ IncrementCounter(COUNTERS->named_store_global_inline(), 1);
2475 __ ret(0); 2476 __ ret(0);
2476 2477
2477 // Handle store cache miss. 2478 // Handle store cache miss.
2478 __ bind(&miss); 2479 __ bind(&miss);
2479 __ IncrementCounter(COUNTERS->named_store_global_inline_miss(), 1); 2480 __ IncrementCounter(COUNTERS->named_store_global_inline_miss(), 1);
2480 Handle<Code> ic(Isolate::Current()->builtins()->builtin( 2481 Handle<Code> ic =
2481 Builtins::StoreIC_Miss)); 2482 Builtins::builtin(Builtins::StoreIC_Miss, masm()->isolate());
2482 __ Jump(ic, RelocInfo::CODE_TARGET); 2483 __ Jump(ic, RelocInfo::CODE_TARGET);
2483 2484
2484 // Return the generated code. 2485 // Return the generated code.
2485 return GetCode(NORMAL, name); 2486 return GetCode(NORMAL, name);
2486 } 2487 }
2487 2488
2488 2489
2489 MaybeObject* KeyedStoreStubCompiler::CompileStoreField(JSObject* object, 2490 MaybeObject* KeyedStoreStubCompiler::CompileStoreField(JSObject* object,
2490 int index, 2491 int index,
2491 Map* transition, 2492 Map* transition,
(...skipping 16 matching lines...) Expand all
2508 GenerateStoreField(masm(), 2509 GenerateStoreField(masm(),
2509 object, 2510 object,
2510 index, 2511 index,
2511 transition, 2512 transition,
2512 rdx, rcx, rbx, 2513 rdx, rcx, rbx,
2513 &miss); 2514 &miss);
2514 2515
2515 // Handle store cache miss. 2516 // Handle store cache miss.
2516 __ bind(&miss); 2517 __ bind(&miss);
2517 __ DecrementCounter(COUNTERS->keyed_store_field(), 1); 2518 __ DecrementCounter(COUNTERS->keyed_store_field(), 1);
2518 Handle<Code> ic(Isolate::Current()->builtins()->builtin( 2519 Handle<Code> ic =
2519 Builtins::KeyedStoreIC_Miss)); 2520 Builtins::builtin(Builtins::KeyedStoreIC_Miss, masm()->isolate());
2520 __ Jump(ic, RelocInfo::CODE_TARGET); 2521 __ Jump(ic, RelocInfo::CODE_TARGET);
2521 2522
2522 // Return the generated code. 2523 // Return the generated code.
2523 return GetCode(transition == NULL ? FIELD : MAP_TRANSITION, name); 2524 return GetCode(transition == NULL ? FIELD : MAP_TRANSITION, name);
2524 } 2525 }
2525 2526
2526 2527
2527 MaybeObject* KeyedStoreStubCompiler::CompileStoreSpecialized( 2528 MaybeObject* KeyedStoreStubCompiler::CompileStoreSpecialized(
2528 JSObject* receiver) { 2529 JSObject* receiver) {
2529 // ----------- S t a t e ------------- 2530 // ----------- S t a t e -------------
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2566 __ SmiToInteger32(rcx, rcx); 2567 __ SmiToInteger32(rcx, rcx);
2567 __ movq(FieldOperand(rdi, rcx, times_pointer_size, FixedArray::kHeaderSize), 2568 __ movq(FieldOperand(rdi, rcx, times_pointer_size, FixedArray::kHeaderSize),
2568 rax); 2569 rax);
2569 __ RecordWrite(rdi, 0, rdx, rcx); 2570 __ RecordWrite(rdi, 0, rdx, rcx);
2570 2571
2571 // Done. 2572 // Done.
2572 __ ret(0); 2573 __ ret(0);
2573 2574
2574 // Handle store cache miss. 2575 // Handle store cache miss.
2575 __ bind(&miss); 2576 __ bind(&miss);
2576 Handle<Code> ic(Isolate::Current()->builtins()->builtin( 2577 Handle<Code> ic =
2577 Builtins::KeyedStoreIC_Miss)); 2578 Builtins::builtin(Builtins::KeyedStoreIC_Miss, masm()->isolate());
2578 __ jmp(ic, RelocInfo::CODE_TARGET); 2579 __ jmp(ic, RelocInfo::CODE_TARGET);
2579 2580
2580 // Return the generated code. 2581 // Return the generated code.
2581 return GetCode(NORMAL, NULL); 2582 return GetCode(NORMAL, NULL);
2582 } 2583 }
2583 2584
2584 2585
2585 MaybeObject* LoadStubCompiler::CompileLoadNonexistent(String* name, 2586 MaybeObject* LoadStubCompiler::CompileLoadNonexistent(String* name,
2586 JSObject* object, 2587 JSObject* object,
2587 JSObject* last) { 2588 JSObject* last) {
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
3136 __ pop(rcx); 3137 __ pop(rcx);
3137 __ lea(rsp, Operand(rsp, rbx, times_pointer_size, 1 * kPointerSize)); 3138 __ lea(rsp, Operand(rsp, rbx, times_pointer_size, 1 * kPointerSize));
3138 __ push(rcx); 3139 __ push(rcx);
3139 __ IncrementCounter(COUNTERS->constructed_objects(), 1); 3140 __ IncrementCounter(COUNTERS->constructed_objects(), 1);
3140 __ IncrementCounter(COUNTERS->constructed_objects_stub(), 1); 3141 __ IncrementCounter(COUNTERS->constructed_objects_stub(), 1);
3141 __ ret(0); 3142 __ ret(0);
3142 3143
3143 // Jump to the generic stub in case the specialized code cannot handle the 3144 // Jump to the generic stub in case the specialized code cannot handle the
3144 // construction. 3145 // construction.
3145 __ bind(&generic_stub_call); 3146 __ bind(&generic_stub_call);
3146 Code* code = Isolate::Current()->builtins()->builtin( 3147 Code* code =
3147 Builtins::JSConstructStubGeneric); 3148 masm()->isolate()->builtins()->builtin(Builtins::JSConstructStubGeneric);
3148 Handle<Code> generic_construct_stub(code); 3149 Handle<Code> generic_construct_stub(code);
3149 __ Jump(generic_construct_stub, RelocInfo::CODE_TARGET); 3150 __ Jump(generic_construct_stub, RelocInfo::CODE_TARGET);
3150 3151
3151 // Return the generated code. 3152 // Return the generated code.
3152 return GetCode(); 3153 return GetCode();
3153 } 3154 }
3154 3155
3155 3156
3156 MaybeObject* ExternalArrayStubCompiler::CompileKeyedLoadStub( 3157 MaybeObject* ExternalArrayStubCompiler::CompileKeyedLoadStub(
3157 JSObject* receiver, ExternalArrayType array_type, Code::Flags flags) { 3158 JSObject* receiver, ExternalArrayType array_type, Code::Flags flags) {
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
3443 __ TailCallRuntime(Runtime::kSetProperty, 5, 1); 3444 __ TailCallRuntime(Runtime::kSetProperty, 5, 1);
3444 3445
3445 return GetCode(flags); 3446 return GetCode(flags);
3446 } 3447 }
3447 3448
3448 #undef __ 3449 #undef __
3449 3450
3450 } } // namespace v8::internal 3451 } } // namespace v8::internal
3451 3452
3452 #endif // V8_TARGET_ARCH_X64 3453 #endif // V8_TARGET_ARCH_X64
OLDNEW
« src/builtins.cc ('K') | « src/x64/macro-assembler-x64.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698