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

Side by Side Diff: src/mips/macro-assembler-mips.cc

Issue 1316543002: MIPS: Correctify instanceof and make it optimizable. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 3 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
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 <limits.h> // For LONG_MIN, LONG_MAX. 5 #include <limits.h> // For LONG_MIN, LONG_MAX.
6 6
7 #if V8_TARGET_ARCH_MIPS 7 #if V8_TARGET_ARCH_MIPS
8 8
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/base/division-by-constant.h" 10 #include "src/base/division-by-constant.h"
(...skipping 4252 matching lines...) Expand 10 before | Expand all | Expand 10 after
4263 bind(&loop); 4263 bind(&loop);
4264 JumpIfSmi(result, &done); 4264 JumpIfSmi(result, &done);
4265 GetObjectType(result, temp, temp2); 4265 GetObjectType(result, temp, temp2);
4266 Branch(&done, ne, temp2, Operand(MAP_TYPE)); 4266 Branch(&done, ne, temp2, Operand(MAP_TYPE));
4267 lw(result, FieldMemOperand(result, Map::kConstructorOrBackPointerOffset)); 4267 lw(result, FieldMemOperand(result, Map::kConstructorOrBackPointerOffset));
4268 Branch(&loop); 4268 Branch(&loop);
4269 bind(&done); 4269 bind(&done);
4270 } 4270 }
4271 4271
4272 4272
4273 void MacroAssembler::TryGetFunctionPrototype(Register function, 4273 void MacroAssembler::TryGetFunctionPrototype(Register function, Register result,
4274 Register result, 4274 Register scratch, Label* miss) {
4275 Register scratch,
4276 Label* miss,
4277 bool miss_on_bound_function) {
4278 Label non_instance;
4279 if (miss_on_bound_function) {
4280 // Check that the receiver isn't a smi.
4281 JumpIfSmi(function, miss);
4282
4283 // Check that the function really is a function. Load map into result reg.
4284 GetObjectType(function, result, scratch);
4285 Branch(miss, ne, scratch, Operand(JS_FUNCTION_TYPE));
4286
4287 lw(scratch,
4288 FieldMemOperand(function, JSFunction::kSharedFunctionInfoOffset));
4289 lw(scratch,
4290 FieldMemOperand(scratch, SharedFunctionInfo::kCompilerHintsOffset));
4291 And(scratch, scratch,
4292 Operand(Smi::FromInt(1 << SharedFunctionInfo::kBoundFunction)));
4293 Branch(miss, ne, scratch, Operand(zero_reg));
4294
4295 // Make sure that the function has an instance prototype.
4296 lbu(scratch, FieldMemOperand(result, Map::kBitFieldOffset));
4297 And(scratch, scratch, Operand(1 << Map::kHasNonInstancePrototype));
4298 Branch(&non_instance, ne, scratch, Operand(zero_reg));
4299 }
4300
4301 // Get the prototype or initial map from the function. 4275 // Get the prototype or initial map from the function.
4302 lw(result, 4276 lw(result,
4303 FieldMemOperand(function, JSFunction::kPrototypeOrInitialMapOffset)); 4277 FieldMemOperand(function, JSFunction::kPrototypeOrInitialMapOffset));
4304 4278
4305 // If the prototype or initial map is the hole, don't return it and 4279 // If the prototype or initial map is the hole, don't return it and
4306 // simply miss the cache instead. This will allow us to allocate a 4280 // simply miss the cache instead. This will allow us to allocate a
4307 // prototype object on-demand in the runtime system. 4281 // prototype object on-demand in the runtime system.
4308 LoadRoot(t8, Heap::kTheHoleValueRootIndex); 4282 LoadRoot(t8, Heap::kTheHoleValueRootIndex);
4309 Branch(miss, eq, result, Operand(t8)); 4283 Branch(miss, eq, result, Operand(t8));
4310 4284
4311 // If the function does not have an initial map, we're done. 4285 // If the function does not have an initial map, we're done.
4312 Label done; 4286 Label done;
4313 GetObjectType(result, scratch, scratch); 4287 GetObjectType(result, scratch, scratch);
4314 Branch(&done, ne, scratch, Operand(MAP_TYPE)); 4288 Branch(&done, ne, scratch, Operand(MAP_TYPE));
4315 4289
4316 // Get the prototype from the initial map. 4290 // Get the prototype from the initial map.
4317 lw(result, FieldMemOperand(result, Map::kPrototypeOffset)); 4291 lw(result, FieldMemOperand(result, Map::kPrototypeOffset));
4318 4292
4319 if (miss_on_bound_function) {
4320 jmp(&done);
4321
4322 // Non-instance prototype: Fetch prototype from constructor field
4323 // in initial map.
4324 bind(&non_instance);
4325 GetMapConstructor(result, result, scratch, scratch);
4326 }
4327
4328 // All done. 4293 // All done.
4329 bind(&done); 4294 bind(&done);
4330 } 4295 }
4331 4296
4332 4297
4333 void MacroAssembler::GetObjectType(Register object, 4298 void MacroAssembler::GetObjectType(Register object,
4334 Register map, 4299 Register map,
4335 Register type_reg) { 4300 Register type_reg) {
4336 lw(map, FieldMemOperand(object, HeapObject::kMapOffset)); 4301 lw(map, FieldMemOperand(object, HeapObject::kMapOffset));
4337 lbu(type_reg, FieldMemOperand(map, Map::kInstanceTypeOffset)); 4302 lbu(type_reg, FieldMemOperand(map, Map::kInstanceTypeOffset));
(...skipping 1778 matching lines...) Expand 10 before | Expand all | Expand 10 after
6116 if (mag.shift > 0) sra(result, result, mag.shift); 6081 if (mag.shift > 0) sra(result, result, mag.shift);
6117 srl(at, dividend, 31); 6082 srl(at, dividend, 31);
6118 Addu(result, result, Operand(at)); 6083 Addu(result, result, Operand(at));
6119 } 6084 }
6120 6085
6121 6086
6122 } // namespace internal 6087 } // namespace internal
6123 } // namespace v8 6088 } // namespace v8
6124 6089
6125 #endif // V8_TARGET_ARCH_MIPS 6090 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « src/mips/macro-assembler-mips.h ('k') | src/mips64/code-stubs-mips64.cc » ('j') | src/objects.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698