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

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

Issue 9298014: MIPS: Implement target cache for constructor calls. (Closed)
Patch Set: Created 8 years, 11 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
« no previous file with comments | « src/mips/builtins-mips.cc ('k') | src/mips/debug-mips.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 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 5323 matching lines...) Expand 10 before | Expand all | Expand 10 after
5334 5334
5335 __ bind(&done); 5335 __ bind(&done);
5336 __ Addu(sp, sp, Operand(3 * kPointerSize)); 5336 __ Addu(sp, sp, Operand(3 * kPointerSize));
5337 __ Ret(); 5337 __ Ret();
5338 5338
5339 __ bind(&slowcase); 5339 __ bind(&slowcase);
5340 __ TailCallRuntime(Runtime::kRegExpConstructResult, 3, 1); 5340 __ TailCallRuntime(Runtime::kRegExpConstructResult, 3, 1);
5341 } 5341 }
5342 5342
5343 5343
5344 void CallFunctionStub::FinishCode(Handle<Code> code) { 5344 static void GenerateRecordCallTarget(MacroAssembler* masm) {
5345 code->set_has_function_cache(false); 5345 // Cache the called function in a global property cell. Cache states
5346 } 5346 // are uninitialized, monomorphic (indicated by a JSFunction), and
5347 // megamorphic.
5348 // a1 : the function to call
5349 // a2 : cache cell for call target
5350 Label done;
5347 5351
5352 ASSERT_EQ(*TypeFeedbackCells::MegamorphicSentinel(masm->isolate()),
5353 masm->isolate()->heap()->undefined_value());
5354 ASSERT_EQ(*TypeFeedbackCells::UninitializedSentinel(masm->isolate()),
5355 masm->isolate()->heap()->the_hole_value());
5348 5356
5349 void CallFunctionStub::Clear(Heap* heap, Address address) { 5357 // Load the cache state into a3.
5350 UNREACHABLE(); 5358 __ lw(a3, FieldMemOperand(a2, JSGlobalPropertyCell::kValueOffset));
5351 }
5352 5359
5360 // A monomorphic cache hit or an already megamorphic state: invoke the
5361 // function without changing the state.
5362 __ Branch(&done, eq, a3, Operand(a1));
5363 __ LoadRoot(at, Heap::kUndefinedValueRootIndex);
5364 __ Branch(&done, eq, a3, Operand(at));
5353 5365
5354 Object* CallFunctionStub::GetCachedValue(Address address) { 5366 // A monomorphic miss (i.e, here the cache is not uninitialized) goes
5355 UNREACHABLE(); 5367 // megamorphic.
5356 return NULL; 5368 __ LoadRoot(at, Heap::kTheHoleValueRootIndex);
5369 __ Branch(&done, eq, a3, Operand(at));
5370 // MegamorphicSentinel is an immortal immovable object (undefined) so no
5371 // write-barrier is needed.
5372 __ LoadRoot(at, Heap::kUndefinedValueRootIndex);
5373 __ sw(at, FieldMemOperand(a2, JSGlobalPropertyCell::kValueOffset));
5374 __ Branch(&done);
5375
5376 // An uninitialized cache is patched with the function.
5377 __ sw(a1, FieldMemOperand(a2, JSGlobalPropertyCell::kValueOffset));
5378 // No need for a write barrier here - cells are rescanned.
5379
5380 __ bind(&done);
5357 } 5381 }
5358 5382
5359 5383
5360 void CallFunctionStub::Generate(MacroAssembler* masm) { 5384 void CallFunctionStub::Generate(MacroAssembler* masm) {
5361 // a1 : the function to call 5385 // a1 : the function to call
5386 // a2 : cache cell for call target
5362 Label slow, non_function; 5387 Label slow, non_function;
5363 5388
5364 // The receiver might implicitly be the global object. This is 5389 // The receiver might implicitly be the global object. This is
5365 // indicated by passing the hole as the receiver to the call 5390 // indicated by passing the hole as the receiver to the call
5366 // function stub. 5391 // function stub.
5367 if (ReceiverMightBeImplicit()) { 5392 if (ReceiverMightBeImplicit()) {
5368 Label call; 5393 Label call;
5369 // Get the receiver from the stack. 5394 // Get the receiver from the stack.
5370 // function, receiver [, arguments] 5395 // function, receiver [, arguments]
5371 __ lw(t0, MemOperand(sp, argc_ * kPointerSize)); 5396 __ lw(t0, MemOperand(sp, argc_ * kPointerSize));
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
5428 __ sw(a1, MemOperand(sp, argc_ * kPointerSize)); 5453 __ sw(a1, MemOperand(sp, argc_ * kPointerSize));
5429 __ li(a0, Operand(argc_)); // Set up the number of arguments. 5454 __ li(a0, Operand(argc_)); // Set up the number of arguments.
5430 __ mov(a2, zero_reg); 5455 __ mov(a2, zero_reg);
5431 __ GetBuiltinEntry(a3, Builtins::CALL_NON_FUNCTION); 5456 __ GetBuiltinEntry(a3, Builtins::CALL_NON_FUNCTION);
5432 __ SetCallKind(t1, CALL_AS_METHOD); 5457 __ SetCallKind(t1, CALL_AS_METHOD);
5433 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), 5458 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(),
5434 RelocInfo::CODE_TARGET); 5459 RelocInfo::CODE_TARGET);
5435 } 5460 }
5436 5461
5437 5462
5463 void CallConstructStub::Generate(MacroAssembler* masm) {
5464 // a0 : number of arguments
5465 // a1 : the function to call
5466 // a2 : cache cell for call target
5467 Label slow, non_function_call;
5468
5469 // Check that the function is not a smi.
5470 __ JumpIfSmi(a1, &non_function_call);
5471 // Check that the function is a JSFunction.
5472 __ GetObjectType(a1, a3, a3);
5473 __ Branch(&slow, ne, a3, Operand(JS_FUNCTION_TYPE));
5474
5475 if (RecordCallTarget()) {
5476 GenerateRecordCallTarget(masm);
5477 }
5478
5479 // Jump to the function-specific construct stub.
5480 __ lw(a2, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset));
5481 __ lw(a2, FieldMemOperand(a2, SharedFunctionInfo::kConstructStubOffset));
5482 __ Addu(at, a2, Operand(Code::kHeaderSize - kHeapObjectTag));
5483 __ Jump(at);
5484
5485 // a0: number of arguments
5486 // a1: called object
5487 // a3: object type
5488 Label do_call;
5489 __ bind(&slow);
5490 __ Branch(&non_function_call, ne, a3, Operand(JS_FUNCTION_PROXY_TYPE));
5491 __ GetBuiltinEntry(a3, Builtins::CALL_FUNCTION_PROXY_AS_CONSTRUCTOR);
5492 __ jmp(&do_call);
5493
5494 __ bind(&non_function_call);
5495 __ GetBuiltinEntry(a3, Builtins::CALL_NON_FUNCTION_AS_CONSTRUCTOR);
5496 __ bind(&do_call);
5497 // Set expected number of arguments to zero (not changing r0).
5498 __ li(a2, Operand(0, RelocInfo::NONE));
5499 __ SetCallKind(t1, CALL_AS_METHOD);
5500 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(),
5501 RelocInfo::CODE_TARGET);
5502 }
5503
5504
5438 // Unfortunately you have to run without snapshots to see most of these 5505 // Unfortunately you have to run without snapshots to see most of these
5439 // names in the profile since most compare stubs end up in the snapshot. 5506 // names in the profile since most compare stubs end up in the snapshot.
5440 void CompareStub::PrintName(StringStream* stream) { 5507 void CompareStub::PrintName(StringStream* stream) {
5441 ASSERT((lhs_.is(a0) && rhs_.is(a1)) || 5508 ASSERT((lhs_.is(a0) && rhs_.is(a1)) ||
5442 (lhs_.is(a1) && rhs_.is(a0))); 5509 (lhs_.is(a1) && rhs_.is(a0)));
5443 const char* cc_name; 5510 const char* cc_name;
5444 switch (cc_) { 5511 switch (cc_) {
5445 case lt: cc_name = "LT"; break; 5512 case lt: cc_name = "LT"; break;
5446 case gt: cc_name = "GT"; break; 5513 case gt: cc_name = "GT"; break;
5447 case le: cc_name = "LE"; break; 5514 case le: cc_name = "LE"; break;
(...skipping 2134 matching lines...) Expand 10 before | Expand all | Expand 10 after
7582 __ Ret(USE_DELAY_SLOT); 7649 __ Ret(USE_DELAY_SLOT);
7583 __ mov(v0, a0); 7650 __ mov(v0, a0);
7584 } 7651 }
7585 7652
7586 7653
7587 #undef __ 7654 #undef __
7588 7655
7589 } } // namespace v8::internal 7656 } } // namespace v8::internal
7590 7657
7591 #endif // V8_TARGET_ARCH_MIPS 7658 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « src/mips/builtins-mips.cc ('k') | src/mips/debug-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698