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

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

Issue 1238253002: MIPS: [stubs] Optimize LoadGlobalViaContextStub and StoreGlobalViaContextStub. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 5 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/interface-descriptors-mips.cc ('k') | src/mips64/full-codegen-mips64.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #if V8_TARGET_ARCH_MIPS64 7 #if V8_TARGET_ARCH_MIPS64
8 8
9 #include "src/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
(...skipping 5289 matching lines...) Expand 10 before | Expand all | Expand 10 after
5300 5300
5301 Label fast_elements_case; 5301 Label fast_elements_case;
5302 __ Branch(&fast_elements_case, eq, a3, Operand(FAST_ELEMENTS)); 5302 __ Branch(&fast_elements_case, eq, a3, Operand(FAST_ELEMENTS));
5303 GenerateCase(masm, FAST_HOLEY_ELEMENTS); 5303 GenerateCase(masm, FAST_HOLEY_ELEMENTS);
5304 5304
5305 __ bind(&fast_elements_case); 5305 __ bind(&fast_elements_case);
5306 GenerateCase(masm, FAST_ELEMENTS); 5306 GenerateCase(masm, FAST_ELEMENTS);
5307 } 5307 }
5308 5308
5309 5309
5310 void LoadGlobalViaContextStub::Generate(MacroAssembler* masm) {
5311 Register context_reg = cp;
5312 Register slot_reg = a2;
5313 Register name_reg = a3;
5314 Register result_reg = v0;
5315 Label slow_case;
5316
5317 // Go up context chain to the script context.
5318 for (int i = 0; i < depth(); ++i) {
5319 __ lw(result_reg, ContextOperand(context_reg, Context::PREVIOUS_INDEX));
5320 context_reg = result_reg;
5321 }
5322
5323 // Load the PropertyCell value at the specified slot.
5324 __ dsll(at, slot_reg, kPointerSizeLog2);
5325 __ Daddu(at, at, Operand(cp));
5326 __ Daddu(at, at, Context::SlotOffset(0));
5327 __ ld(result_reg, MemOperand(at));
5328 __ ld(result_reg, FieldMemOperand(result_reg, PropertyCell::kValueOffset));
5329
5330 // Check that value is not the_hole.
5331 __ LoadRoot(at, Heap::kTheHoleValueRootIndex);
5332 __ Branch(&slow_case, eq, result_reg, Operand(at));
5333 __ Ret();
5334
5335 // Fallback to the runtime.
5336 __ bind(&slow_case);
5337 __ SmiTag(slot_reg);
5338 __ Drop(1); // Pop return address.
5339 __ Push(slot_reg, name_reg, result_reg);
5340 __ TailCallRuntime(Runtime::kLoadGlobalViaContext, 2, 1);
5341 }
5342
5343
5344 void StoreGlobalViaContextStub::Generate(MacroAssembler* masm) {
5345 Register context_reg = cp;
5346 Register slot_reg = a2;
5347 Register name_reg = a3;
5348 Register value_reg = a0;
5349 Register cell_reg = a4;
5350 Register cell_details_reg = a5;
5351 Label fast_case, slow_case;
5352
5353 if (FLAG_debug_code) {
5354 __ LoadRoot(at, Heap::kTheHoleValueRootIndex);
5355 __ Check(ne, kUnexpectedValue, value_reg, Operand(at));
5356 __ AssertName(name_reg);
5357 }
5358
5359 // Go up context chain to the script context.
5360 for (int i = 0; i < depth(); ++i) {
5361 __ ld(cell_reg, ContextOperand(context_reg, Context::PREVIOUS_INDEX));
5362 context_reg = cell_reg;
5363 }
5364
5365 // Load the PropertyCell at the specified slot.
5366 __ dsll(at, slot_reg, kPointerSizeLog2);
5367 __ Daddu(at, at, Operand(cp));
5368 __ Daddu(at, at, Context::SlotOffset(0));
5369 __ ld(cell_reg, MemOperand(at));
5370
5371 // Load PropertyDetails for the cell (actually only the cell_type and kind).
5372 __ ld(cell_details_reg,
5373 FieldMemOperand(cell_reg, PropertyCell::kDetailsOffset));
5374 __ SmiUntag(cell_details_reg);
5375 __ And(cell_details_reg, cell_details_reg,
5376 PropertyDetails::PropertyCellTypeField::kMask |
5377 PropertyDetails::KindField::kMask);
5378
5379 // Check if PropertyCell holds mutable data.
5380 Label not_mutable_data;
5381 __ Branch(&not_mutable_data, ne, cell_details_reg,
5382 Operand(PropertyDetails::PropertyCellTypeField::encode(
5383 PropertyCellType::kMutable) |
5384 PropertyDetails::KindField::encode(kData)));
5385 __ bind(&fast_case);
5386 __ sd(value_reg, FieldMemOperand(cell_reg, PropertyCell::kValueOffset));
5387 __ RecordWriteField(cell_reg, PropertyCell::kValueOffset, value_reg,
5388 cell_details_reg, kRAHasNotBeenSaved, kDontSaveFPRegs);
5389 // RecordWriteField clobbers the value register, so we need to reload.
5390 __ Ret(USE_DELAY_SLOT);
5391 __ ld(value_reg, FieldMemOperand(cell_reg, PropertyCell::kValueOffset));
5392 __ bind(&not_mutable_data);
5393
5394 // Check if PropertyCell value matches the new value (relevant for Constant
5395 // and ConstantType cells).
5396 Label not_same_value;
5397 __ ld(at, FieldMemOperand(cell_reg, PropertyCell::kValueOffset));
5398 __ Branch(&not_same_value, ne, value_reg, Operand(at));
5399 if (FLAG_debug_code) {
5400 Label done;
5401 // This can only be true for Constant and ConstantType cells, because we
5402 // never store the_hole via this stub.
5403 __ Branch(&done, eq, cell_details_reg,
5404 Operand(PropertyDetails::PropertyCellTypeField::encode(
5405 PropertyCellType::kConstant) |
5406 PropertyDetails::KindField::encode(kData)));
5407 __ Check(eq, kUnexpectedValue, cell_details_reg,
5408 Operand(PropertyDetails::PropertyCellTypeField::encode(
5409 PropertyCellType::kConstantType) |
5410 PropertyDetails::KindField::encode(kData)));
5411 __ bind(&done);
5412 }
5413 __ Ret();
5414 __ bind(&not_same_value);
5415
5416 // Check if PropertyCell contains data with constant type.
5417 __ Branch(&slow_case, ne, cell_details_reg,
5418 Operand(PropertyDetails::PropertyCellTypeField::encode(
5419 PropertyCellType::kConstantType) |
5420 PropertyDetails::KindField::encode(kData)));
5421
5422 // Now either both old and new values must be SMIs or both must be heap
5423 // objects with same map.
5424 Label value_is_heap_object;
5425 Register cell_value_reg = cell_details_reg;
5426 __ ld(cell_value_reg, FieldMemOperand(cell_reg, PropertyCell::kValueOffset));
5427 __ JumpIfNotSmi(value_reg, &value_is_heap_object);
5428 __ JumpIfNotSmi(cell_value_reg, &slow_case);
5429 // Old and new values are SMIs, no need for a write barrier here.
5430 __ Ret(USE_DELAY_SLOT);
5431 __ sd(value_reg, FieldMemOperand(cell_reg, PropertyCell::kValueOffset));
5432 __ bind(&value_is_heap_object);
5433 __ JumpIfSmi(cell_value_reg, &slow_case);
5434 Register cell_value_map_reg = cell_value_reg;
5435 __ ld(cell_value_map_reg,
5436 FieldMemOperand(cell_value_reg, HeapObject::kMapOffset));
5437 __ Branch(&fast_case, eq, cell_value_map_reg,
5438 FieldMemOperand(value_reg, HeapObject::kMapOffset));
5439
5440 // Fallback to the runtime.
5441 __ bind(&slow_case);
5442 __ SmiTag(slot_reg);
5443 __ Drop(1); // Pop return address.
5444 __ Push(slot_reg, name_reg, value_reg, cell_reg);
5445 __ TailCallRuntime(is_strict(language_mode())
5446 ? Runtime::kStoreGlobalViaContext_Strict
5447 : Runtime::kStoreGlobalViaContext_Sloppy,
5448 3, 1);
5449 }
5450
5451
5310 static int AddressOffset(ExternalReference ref0, ExternalReference ref1) { 5452 static int AddressOffset(ExternalReference ref0, ExternalReference ref1) {
5311 int64_t offset = (ref0.address() - ref1.address()); 5453 int64_t offset = (ref0.address() - ref1.address());
5312 DCHECK(static_cast<int>(offset) == offset); 5454 DCHECK(static_cast<int>(offset) == offset);
5313 return static_cast<int>(offset); 5455 return static_cast<int>(offset);
5314 } 5456 }
5315 5457
5316 5458
5317 // Calls an API function. Allocates HandleScope, extracts returned value 5459 // Calls an API function. Allocates HandleScope, extracts returned value
5318 // from handle and propagates exceptions. Restores context. stack_space 5460 // from handle and propagates exceptions. Restores context. stack_space
5319 // - space to be unwound on exit (includes the call JS arguments space and 5461 // - space to be unwound on exit (includes the call JS arguments space and
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
5610 MemOperand(fp, 6 * kPointerSize), NULL); 5752 MemOperand(fp, 6 * kPointerSize), NULL);
5611 } 5753 }
5612 5754
5613 5755
5614 #undef __ 5756 #undef __
5615 5757
5616 } // namespace internal 5758 } // namespace internal
5617 } // namespace v8 5759 } // namespace v8
5618 5760
5619 #endif // V8_TARGET_ARCH_MIPS64 5761 #endif // V8_TARGET_ARCH_MIPS64
OLDNEW
« no previous file with comments | « src/mips/interface-descriptors-mips.cc ('k') | src/mips64/full-codegen-mips64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698