blob: 7c8a5eacabfd37a003d041945eeaa8dc6880bc83 [file] [log] [blame]
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001// 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
3// found in the LICENSE file.
4
5
6#include "src/v8.h"
7
8#if V8_TARGET_ARCH_MIPS
9
10#include "src/codegen.h"
11#include "src/ic/ic.h"
12#include "src/ic/ic-compiler.h"
13#include "src/ic/stub-cache.h"
14
15namespace v8 {
16namespace internal {
17
18
19// ----------------------------------------------------------------------------
20// Static IC stub generators.
21//
22
23#define __ ACCESS_MASM(masm)
24
25
26static void GenerateGlobalInstanceTypeCheck(MacroAssembler* masm, Register type,
27 Label* global_object) {
28 // Register usage:
29 // type: holds the receiver instance type on entry.
30 __ Branch(global_object, eq, type, Operand(JS_GLOBAL_OBJECT_TYPE));
31 __ Branch(global_object, eq, type, Operand(JS_BUILTINS_OBJECT_TYPE));
32 __ Branch(global_object, eq, type, Operand(JS_GLOBAL_PROXY_TYPE));
33}
34
35
36// Helper function used from LoadIC GenerateNormal.
37//
38// elements: Property dictionary. It is not clobbered if a jump to the miss
39// label is done.
40// name: Property name. It is not clobbered if a jump to the miss label is
41// done
42// result: Register for the result. It is only updated if a jump to the miss
43// label is not done. Can be the same as elements or name clobbering
44// one of these in the case of not jumping to the miss label.
45// The two scratch registers need to be different from elements, name and
46// result.
47// The generated code assumes that the receiver has slow properties,
48// is not a global object and does not have interceptors.
49// The address returned from GenerateStringDictionaryProbes() in scratch2
50// is used.
51static void GenerateDictionaryLoad(MacroAssembler* masm, Label* miss,
52 Register elements, Register name,
53 Register result, Register scratch1,
54 Register scratch2) {
55 // Main use of the scratch registers.
56 // scratch1: Used as temporary and to hold the capacity of the property
57 // dictionary.
58 // scratch2: Used as temporary.
59 Label done;
60
61 // Probe the dictionary.
62 NameDictionaryLookupStub::GeneratePositiveLookup(masm, miss, &done, elements,
63 name, scratch1, scratch2);
64
65 // If probing finds an entry check that the value is a normal
66 // property.
67 __ bind(&done); // scratch2 == elements + 4 * index.
68 const int kElementsStartOffset =
69 NameDictionary::kHeaderSize +
70 NameDictionary::kElementsStartIndex * kPointerSize;
71 const int kDetailsOffset = kElementsStartOffset + 2 * kPointerSize;
72 __ lw(scratch1, FieldMemOperand(scratch2, kDetailsOffset));
73 __ And(at, scratch1,
74 Operand(PropertyDetails::TypeField::kMask << kSmiTagSize));
75 __ Branch(miss, ne, at, Operand(zero_reg));
76
77 // Get the value at the masked, scaled index and return.
78 __ lw(result,
79 FieldMemOperand(scratch2, kElementsStartOffset + 1 * kPointerSize));
80}
81
82
83// Helper function used from StoreIC::GenerateNormal.
84//
85// elements: Property dictionary. It is not clobbered if a jump to the miss
86// label is done.
87// name: Property name. It is not clobbered if a jump to the miss label is
88// done
89// value: The value to store.
90// The two scratch registers need to be different from elements, name and
91// result.
92// The generated code assumes that the receiver has slow properties,
93// is not a global object and does not have interceptors.
94// The address returned from GenerateStringDictionaryProbes() in scratch2
95// is used.
96static void GenerateDictionaryStore(MacroAssembler* masm, Label* miss,
97 Register elements, Register name,
98 Register value, Register scratch1,
99 Register scratch2) {
100 // Main use of the scratch registers.
101 // scratch1: Used as temporary and to hold the capacity of the property
102 // dictionary.
103 // scratch2: Used as temporary.
104 Label done;
105
106 // Probe the dictionary.
107 NameDictionaryLookupStub::GeneratePositiveLookup(masm, miss, &done, elements,
108 name, scratch1, scratch2);
109
110 // If probing finds an entry in the dictionary check that the value
111 // is a normal property that is not read only.
112 __ bind(&done); // scratch2 == elements + 4 * index.
113 const int kElementsStartOffset =
114 NameDictionary::kHeaderSize +
115 NameDictionary::kElementsStartIndex * kPointerSize;
116 const int kDetailsOffset = kElementsStartOffset + 2 * kPointerSize;
117 const int kTypeAndReadOnlyMask =
118 (PropertyDetails::TypeField::kMask |
119 PropertyDetails::AttributesField::encode(READ_ONLY))
120 << kSmiTagSize;
121 __ lw(scratch1, FieldMemOperand(scratch2, kDetailsOffset));
122 __ And(at, scratch1, Operand(kTypeAndReadOnlyMask));
123 __ Branch(miss, ne, at, Operand(zero_reg));
124
125 // Store the value at the masked, scaled index and return.
126 const int kValueOffset = kElementsStartOffset + kPointerSize;
127 __ Addu(scratch2, scratch2, Operand(kValueOffset - kHeapObjectTag));
128 __ sw(value, MemOperand(scratch2));
129
130 // Update the write barrier. Make sure not to clobber the value.
131 __ mov(scratch1, value);
132 __ RecordWrite(elements, scratch2, scratch1, kRAHasNotBeenSaved,
133 kDontSaveFPRegs);
134}
135
136
137// Checks the receiver for special cases (value type, slow case bits).
138// Falls through for regular JS object.
139static void GenerateKeyedLoadReceiverCheck(MacroAssembler* masm,
140 Register receiver, Register map,
141 Register scratch,
142 int interceptor_bit, Label* slow) {
143 // Check that the object isn't a smi.
144 __ JumpIfSmi(receiver, slow);
145 // Get the map of the receiver.
146 __ lw(map, FieldMemOperand(receiver, HeapObject::kMapOffset));
147 // Check bit field.
148 __ lbu(scratch, FieldMemOperand(map, Map::kBitFieldOffset));
149 __ And(at, scratch,
150 Operand((1 << Map::kIsAccessCheckNeeded) | (1 << interceptor_bit)));
151 __ Branch(slow, ne, at, Operand(zero_reg));
152 // Check that the object is some kind of JS object EXCEPT JS Value type.
153 // In the case that the object is a value-wrapper object,
154 // we enter the runtime system to make sure that indexing into string
155 // objects work as intended.
156 DCHECK(JS_OBJECT_TYPE > JS_VALUE_TYPE);
157 __ lbu(scratch, FieldMemOperand(map, Map::kInstanceTypeOffset));
158 __ Branch(slow, lt, scratch, Operand(JS_OBJECT_TYPE));
159}
160
161
162// Loads an indexed element from a fast case array.
163// If not_fast_array is NULL, doesn't perform the elements map check.
164static void GenerateFastArrayLoad(MacroAssembler* masm, Register receiver,
165 Register key, Register elements,
166 Register scratch1, Register scratch2,
167 Register result, Label* not_fast_array,
168 Label* out_of_range) {
169 // Register use:
170 //
171 // receiver - holds the receiver on entry.
172 // Unchanged unless 'result' is the same register.
173 //
174 // key - holds the smi key on entry.
175 // Unchanged unless 'result' is the same register.
176 //
177 // elements - holds the elements of the receiver on exit.
178 //
179 // result - holds the result on exit if the load succeeded.
180 // Allowed to be the the same as 'receiver' or 'key'.
181 // Unchanged on bailout so 'receiver' and 'key' can be safely
182 // used by further computation.
183 //
184 // Scratch registers:
185 //
186 // scratch1 - used to hold elements map and elements length.
187 // Holds the elements map if not_fast_array branch is taken.
188 //
189 // scratch2 - used to hold the loaded value.
190
191 __ lw(elements, FieldMemOperand(receiver, JSObject::kElementsOffset));
192 if (not_fast_array != NULL) {
193 // Check that the object is in fast mode (not dictionary).
194 __ lw(scratch1, FieldMemOperand(elements, HeapObject::kMapOffset));
195 __ LoadRoot(at, Heap::kFixedArrayMapRootIndex);
196 __ Branch(not_fast_array, ne, scratch1, Operand(at));
197 } else {
198 __ AssertFastElements(elements);
199 }
200
201 // Check that the key (index) is within bounds.
202 __ lw(scratch1, FieldMemOperand(elements, FixedArray::kLengthOffset));
203 __ Branch(out_of_range, hs, key, Operand(scratch1));
204
205 // Fast case: Do the load.
206 __ Addu(scratch1, elements,
207 Operand(FixedArray::kHeaderSize - kHeapObjectTag));
208 // The key is a smi.
209 STATIC_ASSERT(kSmiTag == 0 && kSmiTagSize < kPointerSizeLog2);
210 __ sll(at, key, kPointerSizeLog2 - kSmiTagSize);
211 __ addu(at, at, scratch1);
212 __ lw(scratch2, MemOperand(at));
213
214 __ LoadRoot(at, Heap::kTheHoleValueRootIndex);
215 // In case the loaded value is the_hole we have to consult GetProperty
216 // to ensure the prototype chain is searched.
217 __ Branch(out_of_range, eq, scratch2, Operand(at));
218 __ mov(result, scratch2);
219}
220
221
222// Checks whether a key is an array index string or a unique name.
223// Falls through if a key is a unique name.
224static void GenerateKeyNameCheck(MacroAssembler* masm, Register key,
225 Register map, Register hash,
226 Label* index_string, Label* not_unique) {
227 // The key is not a smi.
228 Label unique;
229 // Is it a name?
230 __ GetObjectType(key, map, hash);
231 __ Branch(not_unique, hi, hash, Operand(LAST_UNIQUE_NAME_TYPE));
232 STATIC_ASSERT(LAST_UNIQUE_NAME_TYPE == FIRST_NONSTRING_TYPE);
233 __ Branch(&unique, eq, hash, Operand(LAST_UNIQUE_NAME_TYPE));
234
235 // Is the string an array index, with cached numeric value?
236 __ lw(hash, FieldMemOperand(key, Name::kHashFieldOffset));
237 __ And(at, hash, Operand(Name::kContainsCachedArrayIndexMask));
238 __ Branch(index_string, eq, at, Operand(zero_reg));
239
240 // Is the string internalized? We know it's a string, so a single
241 // bit test is enough.
242 // map: key map
243 __ lbu(hash, FieldMemOperand(map, Map::kInstanceTypeOffset));
244 STATIC_ASSERT(kInternalizedTag == 0);
245 __ And(at, hash, Operand(kIsNotInternalizedMask));
246 __ Branch(not_unique, ne, at, Operand(zero_reg));
247
248 __ bind(&unique);
249}
250
251
252void LoadIC::GenerateNormal(MacroAssembler* masm) {
253 Register dictionary = a0;
254 DCHECK(!dictionary.is(LoadDescriptor::ReceiverRegister()));
255 DCHECK(!dictionary.is(LoadDescriptor::NameRegister()));
256
257 Label slow;
258
259 __ lw(dictionary, FieldMemOperand(LoadDescriptor::ReceiverRegister(),
260 JSObject::kPropertiesOffset));
261 GenerateDictionaryLoad(masm, &slow, dictionary,
262 LoadDescriptor::NameRegister(), v0, a3, t0);
263 __ Ret();
264
265 // Dictionary load failed, go slow (but don't miss).
266 __ bind(&slow);
267 GenerateRuntimeGetProperty(masm);
268}
269
270
271// A register that isn't one of the parameters to the load ic.
272static const Register LoadIC_TempRegister() { return a3; }
273
274
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400275static void LoadIC_PushArgs(MacroAssembler* masm) {
276 Register receiver = LoadDescriptor::ReceiverRegister();
277 Register name = LoadDescriptor::NameRegister();
278 if (FLAG_vector_ics) {
279 Register slot = VectorLoadICDescriptor::SlotRegister();
280 Register vector = VectorLoadICDescriptor::VectorRegister();
281
282 __ Push(receiver, name, slot, vector);
283 } else {
284 __ Push(receiver, name);
285 }
286}
287
288
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000289void LoadIC::GenerateMiss(MacroAssembler* masm) {
290 // The return address is in ra.
291 Isolate* isolate = masm->isolate();
292
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400293 DCHECK(!FLAG_vector_ics ||
294 !AreAliased(t0, t1, VectorLoadICDescriptor::SlotRegister(),
295 VectorLoadICDescriptor::VectorRegister()));
296 __ IncrementCounter(isolate->counters()->load_miss(), 1, t0, t1);
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000297
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400298 LoadIC_PushArgs(masm);
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000299
300 // Perform tail call to the entry.
301 ExternalReference ref = ExternalReference(IC_Utility(kLoadIC_Miss), isolate);
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400302 int arg_count = FLAG_vector_ics ? 4 : 2;
303 __ TailCallExternalReference(ref, arg_count, 1);
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000304}
305
306
307void LoadIC::GenerateRuntimeGetProperty(MacroAssembler* masm) {
308 // The return address is in ra.
309
310 __ mov(LoadIC_TempRegister(), LoadDescriptor::ReceiverRegister());
311 __ Push(LoadIC_TempRegister(), LoadDescriptor::NameRegister());
312
313 __ TailCallRuntime(Runtime::kGetProperty, 2, 1);
314}
315
316
317static MemOperand GenerateMappedArgumentsLookup(
318 MacroAssembler* masm, Register object, Register key, Register scratch1,
319 Register scratch2, Register scratch3, Label* unmapped_case,
320 Label* slow_case) {
321 Heap* heap = masm->isolate()->heap();
322
323 // Check that the receiver is a JSObject. Because of the map check
324 // later, we do not need to check for interceptors or whether it
325 // requires access checks.
326 __ JumpIfSmi(object, slow_case);
327 // Check that the object is some kind of JSObject.
328 __ GetObjectType(object, scratch1, scratch2);
329 __ Branch(slow_case, lt, scratch2, Operand(FIRST_JS_RECEIVER_TYPE));
330
331 // Check that the key is a positive smi.
332 __ And(scratch1, key, Operand(0x80000001));
333 __ Branch(slow_case, ne, scratch1, Operand(zero_reg));
334
335 // Load the elements into scratch1 and check its map.
336 Handle<Map> arguments_map(heap->sloppy_arguments_elements_map());
337 __ lw(scratch1, FieldMemOperand(object, JSObject::kElementsOffset));
338 __ CheckMap(scratch1, scratch2, arguments_map, slow_case, DONT_DO_SMI_CHECK);
339 // Check if element is in the range of mapped arguments. If not, jump
340 // to the unmapped lookup with the parameter map in scratch1.
341 __ lw(scratch2, FieldMemOperand(scratch1, FixedArray::kLengthOffset));
342 __ Subu(scratch2, scratch2, Operand(Smi::FromInt(2)));
343 __ Branch(unmapped_case, Ugreater_equal, key, Operand(scratch2));
344
345 // Load element index and check whether it is the hole.
346 const int kOffset =
347 FixedArray::kHeaderSize + 2 * kPointerSize - kHeapObjectTag;
348
349 __ li(scratch3, Operand(kPointerSize >> 1));
350 __ Mul(scratch3, key, scratch3);
351 __ Addu(scratch3, scratch3, Operand(kOffset));
352
353 __ Addu(scratch2, scratch1, scratch3);
354 __ lw(scratch2, MemOperand(scratch2));
355 __ LoadRoot(scratch3, Heap::kTheHoleValueRootIndex);
356 __ Branch(unmapped_case, eq, scratch2, Operand(scratch3));
357
358 // Load value from context and return it. We can reuse scratch1 because
359 // we do not jump to the unmapped lookup (which requires the parameter
360 // map in scratch1).
361 __ lw(scratch1, FieldMemOperand(scratch1, FixedArray::kHeaderSize));
362 __ li(scratch3, Operand(kPointerSize >> 1));
363 __ Mul(scratch3, scratch2, scratch3);
364 __ Addu(scratch3, scratch3, Operand(Context::kHeaderSize - kHeapObjectTag));
365 __ Addu(scratch2, scratch1, scratch3);
366 return MemOperand(scratch2);
367}
368
369
370static MemOperand GenerateUnmappedArgumentsLookup(MacroAssembler* masm,
371 Register key,
372 Register parameter_map,
373 Register scratch,
374 Label* slow_case) {
375 // Element is in arguments backing store, which is referenced by the
376 // second element of the parameter_map. The parameter_map register
377 // must be loaded with the parameter map of the arguments object and is
378 // overwritten.
379 const int kBackingStoreOffset = FixedArray::kHeaderSize + kPointerSize;
380 Register backing_store = parameter_map;
381 __ lw(backing_store, FieldMemOperand(parameter_map, kBackingStoreOffset));
382 __ CheckMap(backing_store, scratch, Heap::kFixedArrayMapRootIndex, slow_case,
383 DONT_DO_SMI_CHECK);
384 __ lw(scratch, FieldMemOperand(backing_store, FixedArray::kLengthOffset));
385 __ Branch(slow_case, Ugreater_equal, key, Operand(scratch));
386 __ li(scratch, Operand(kPointerSize >> 1));
387 __ Mul(scratch, key, scratch);
388 __ Addu(scratch, scratch, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
389 __ Addu(scratch, backing_store, scratch);
390 return MemOperand(scratch);
391}
392
393
394void KeyedStoreIC::GenerateSloppyArguments(MacroAssembler* masm) {
395 Register receiver = StoreDescriptor::ReceiverRegister();
396 Register key = StoreDescriptor::NameRegister();
397 Register value = StoreDescriptor::ValueRegister();
398 DCHECK(value.is(a0));
399
400 Label slow, notin;
401 // Store address is returned in register (of MemOperand) mapped_location.
402 MemOperand mapped_location = GenerateMappedArgumentsLookup(
403 masm, receiver, key, a3, t0, t1, &notin, &slow);
404 __ sw(value, mapped_location);
405 __ mov(t5, value);
406 DCHECK_EQ(mapped_location.offset(), 0);
407 __ RecordWrite(a3, mapped_location.rm(), t5, kRAHasNotBeenSaved,
408 kDontSaveFPRegs);
409 __ Ret(USE_DELAY_SLOT);
410 __ mov(v0, value); // (In delay slot) return the value stored in v0.
411 __ bind(&notin);
412 // The unmapped lookup expects that the parameter map is in a3.
413 // Store address is returned in register (of MemOperand) unmapped_location.
414 MemOperand unmapped_location =
415 GenerateUnmappedArgumentsLookup(masm, key, a3, t0, &slow);
416 __ sw(value, unmapped_location);
417 __ mov(t5, value);
418 DCHECK_EQ(unmapped_location.offset(), 0);
419 __ RecordWrite(a3, unmapped_location.rm(), t5, kRAHasNotBeenSaved,
420 kDontSaveFPRegs);
421 __ Ret(USE_DELAY_SLOT);
422 __ mov(v0, a0); // (In delay slot) return the value stored in v0.
423 __ bind(&slow);
424 GenerateMiss(masm);
425}
426
427
428void KeyedLoadIC::GenerateMiss(MacroAssembler* masm) {
429 // The return address is in ra.
430 Isolate* isolate = masm->isolate();
431
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400432 DCHECK(!FLAG_vector_ics ||
433 !AreAliased(t0, t1, VectorLoadICDescriptor::SlotRegister(),
434 VectorLoadICDescriptor::VectorRegister()));
435 __ IncrementCounter(isolate->counters()->keyed_load_miss(), 1, t0, t1);
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000436
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400437 LoadIC_PushArgs(masm);
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000438
439 // Perform tail call to the entry.
440 ExternalReference ref =
441 ExternalReference(IC_Utility(kKeyedLoadIC_Miss), isolate);
442
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400443 int arg_count = FLAG_vector_ics ? 4 : 2;
444 __ TailCallExternalReference(ref, arg_count, 1);
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000445}
446
447
448void KeyedLoadIC::GenerateRuntimeGetProperty(MacroAssembler* masm) {
449 // The return address is in ra.
450
451 __ Push(LoadDescriptor::ReceiverRegister(), LoadDescriptor::NameRegister());
452
453 __ TailCallRuntime(Runtime::kKeyedGetProperty, 2, 1);
454}
455
456
457void KeyedLoadIC::GenerateGeneric(MacroAssembler* masm) {
458 // The return address is in ra.
459 Label slow, check_name, index_smi, index_name, property_array_property;
460 Label probe_dictionary, check_number_dictionary;
461
462 Register key = LoadDescriptor::NameRegister();
463 Register receiver = LoadDescriptor::ReceiverRegister();
464 DCHECK(key.is(a2));
465 DCHECK(receiver.is(a1));
466
467 Isolate* isolate = masm->isolate();
468
469 // Check that the key is a smi.
470 __ JumpIfNotSmi(key, &check_name);
471 __ bind(&index_smi);
472 // Now the key is known to be a smi. This place is also jumped to from below
473 // where a numeric string is converted to a smi.
474
475 GenerateKeyedLoadReceiverCheck(masm, receiver, a0, a3,
476 Map::kHasIndexedInterceptor, &slow);
477
478 // Check the receiver's map to see if it has fast elements.
479 __ CheckFastElements(a0, a3, &check_number_dictionary);
480
481 GenerateFastArrayLoad(masm, receiver, key, a0, a3, t0, v0, NULL, &slow);
482 __ IncrementCounter(isolate->counters()->keyed_load_generic_smi(), 1, t0, a3);
483 __ Ret();
484
485 __ bind(&check_number_dictionary);
486 __ lw(t0, FieldMemOperand(receiver, JSObject::kElementsOffset));
487 __ lw(a3, FieldMemOperand(t0, JSObject::kMapOffset));
488
489 // Check whether the elements is a number dictionary.
490 // a3: elements map
491 // t0: elements
492 __ LoadRoot(at, Heap::kHashTableMapRootIndex);
493 __ Branch(&slow, ne, a3, Operand(at));
494 __ sra(a0, key, kSmiTagSize);
495 __ LoadFromNumberDictionary(&slow, t0, key, v0, a0, a3, t1);
496 __ Ret();
497
498 // Slow case, key and receiver still in a2 and a1.
499 __ bind(&slow);
500 __ IncrementCounter(isolate->counters()->keyed_load_generic_slow(), 1, t0,
501 a3);
502 GenerateRuntimeGetProperty(masm);
503
504 __ bind(&check_name);
505 GenerateKeyNameCheck(masm, key, a0, a3, &index_name, &slow);
506
507 GenerateKeyedLoadReceiverCheck(masm, receiver, a0, a3,
508 Map::kHasNamedInterceptor, &slow);
509
510
511 // If the receiver is a fast-case object, check the keyed lookup
512 // cache. Otherwise probe the dictionary.
513 __ lw(a3, FieldMemOperand(receiver, JSObject::kPropertiesOffset));
514 __ lw(t0, FieldMemOperand(a3, HeapObject::kMapOffset));
515 __ LoadRoot(at, Heap::kHashTableMapRootIndex);
516 __ Branch(&probe_dictionary, eq, t0, Operand(at));
517
518 // Load the map of the receiver, compute the keyed lookup cache hash
519 // based on 32 bits of the map pointer and the name hash.
520 __ lw(a0, FieldMemOperand(receiver, HeapObject::kMapOffset));
521 __ sra(a3, a0, KeyedLookupCache::kMapHashShift);
522 __ lw(t0, FieldMemOperand(key, Name::kHashFieldOffset));
523 __ sra(at, t0, Name::kHashShift);
524 __ xor_(a3, a3, at);
525 int mask = KeyedLookupCache::kCapacityMask & KeyedLookupCache::kHashMask;
526 __ And(a3, a3, Operand(mask));
527
528 // Load the key (consisting of map and unique name) from the cache and
529 // check for match.
530 Label load_in_object_property;
531 static const int kEntriesPerBucket = KeyedLookupCache::kEntriesPerBucket;
532 Label hit_on_nth_entry[kEntriesPerBucket];
533 ExternalReference cache_keys =
534 ExternalReference::keyed_lookup_cache_keys(isolate);
535 __ li(t0, Operand(cache_keys));
536 __ sll(at, a3, kPointerSizeLog2 + 1);
537 __ addu(t0, t0, at);
538
539 for (int i = 0; i < kEntriesPerBucket - 1; i++) {
540 Label try_next_entry;
541 __ lw(t1, MemOperand(t0, kPointerSize * i * 2));
542 __ Branch(&try_next_entry, ne, a0, Operand(t1));
543 __ lw(t1, MemOperand(t0, kPointerSize * (i * 2 + 1)));
544 __ Branch(&hit_on_nth_entry[i], eq, key, Operand(t1));
545 __ bind(&try_next_entry);
546 }
547
548 __ lw(t1, MemOperand(t0, kPointerSize * (kEntriesPerBucket - 1) * 2));
549 __ Branch(&slow, ne, a0, Operand(t1));
550 __ lw(t1, MemOperand(t0, kPointerSize * ((kEntriesPerBucket - 1) * 2 + 1)));
551 __ Branch(&slow, ne, key, Operand(t1));
552
553 // Get field offset.
554 // a0 : receiver's map
555 // a3 : lookup cache index
556 ExternalReference cache_field_offsets =
557 ExternalReference::keyed_lookup_cache_field_offsets(isolate);
558
559 // Hit on nth entry.
560 for (int i = kEntriesPerBucket - 1; i >= 0; i--) {
561 __ bind(&hit_on_nth_entry[i]);
562 __ li(t0, Operand(cache_field_offsets));
563 __ sll(at, a3, kPointerSizeLog2);
564 __ addu(at, t0, at);
565 __ lw(t1, MemOperand(at, kPointerSize * i));
566 __ lbu(t2, FieldMemOperand(a0, Map::kInObjectPropertiesOffset));
567 __ Subu(t1, t1, t2);
568 __ Branch(&property_array_property, ge, t1, Operand(zero_reg));
569 if (i != 0) {
570 __ Branch(&load_in_object_property);
571 }
572 }
573
574 // Load in-object property.
575 __ bind(&load_in_object_property);
576 __ lbu(t2, FieldMemOperand(a0, Map::kInstanceSizeOffset));
577 __ addu(t2, t2, t1); // Index from start of object.
578 __ Subu(receiver, receiver, Operand(kHeapObjectTag)); // Remove the heap tag.
579 __ sll(at, t2, kPointerSizeLog2);
580 __ addu(at, receiver, at);
581 __ lw(v0, MemOperand(at));
582 __ IncrementCounter(isolate->counters()->keyed_load_generic_lookup_cache(), 1,
583 t0, a3);
584 __ Ret();
585
586 // Load property array property.
587 __ bind(&property_array_property);
588 __ lw(receiver, FieldMemOperand(receiver, JSObject::kPropertiesOffset));
589 __ Addu(receiver, receiver, FixedArray::kHeaderSize - kHeapObjectTag);
590 __ sll(v0, t1, kPointerSizeLog2);
591 __ Addu(v0, v0, receiver);
592 __ lw(v0, MemOperand(v0));
593 __ IncrementCounter(isolate->counters()->keyed_load_generic_lookup_cache(), 1,
594 t0, a3);
595 __ Ret();
596
597
598 // Do a quick inline probe of the receiver's dictionary, if it
599 // exists.
600 __ bind(&probe_dictionary);
601 // a3: elements
602 __ lw(a0, FieldMemOperand(receiver, HeapObject::kMapOffset));
603 __ lbu(a0, FieldMemOperand(a0, Map::kInstanceTypeOffset));
604 GenerateGlobalInstanceTypeCheck(masm, a0, &slow);
605 // Load the property to v0.
606 GenerateDictionaryLoad(masm, &slow, a3, key, v0, t1, t0);
607 __ IncrementCounter(isolate->counters()->keyed_load_generic_symbol(), 1, t0,
608 a3);
609 __ Ret();
610
611 __ bind(&index_name);
612 __ IndexFromHash(a3, key);
613 // Now jump to the place where smi keys are handled.
614 __ Branch(&index_smi);
615}
616
617
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400618static void KeyedStoreGenerateMegamorphicHelper(
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000619 MacroAssembler* masm, Label* fast_object, Label* fast_double, Label* slow,
620 KeyedStoreCheckMap check_map, KeyedStoreIncrementLength increment_length,
621 Register value, Register key, Register receiver, Register receiver_map,
622 Register elements_map, Register elements) {
623 Label transition_smi_elements;
624 Label finish_object_store, non_double_value, transition_double_elements;
625 Label fast_double_without_map_check;
626
627 // Fast case: Do the store, could be either Object or double.
628 __ bind(fast_object);
629 Register scratch_value = t0;
630 Register address = t1;
631 if (check_map == kCheckMap) {
632 __ lw(elements_map, FieldMemOperand(elements, HeapObject::kMapOffset));
633 __ Branch(fast_double, ne, elements_map,
634 Operand(masm->isolate()->factory()->fixed_array_map()));
635 }
636
637 // HOLECHECK: guards "A[i] = V"
638 // We have to go to the runtime if the current value is the hole because
639 // there may be a callback on the element.
640 Label holecheck_passed1;
641 __ Addu(address, elements, FixedArray::kHeaderSize - kHeapObjectTag);
642 __ sll(at, key, kPointerSizeLog2 - kSmiTagSize);
643 __ addu(address, address, at);
644 __ lw(scratch_value, MemOperand(address));
645 __ Branch(&holecheck_passed1, ne, scratch_value,
646 Operand(masm->isolate()->factory()->the_hole_value()));
647 __ JumpIfDictionaryInPrototypeChain(receiver, elements_map, scratch_value,
648 slow);
649
650 __ bind(&holecheck_passed1);
651
652 // Smi stores don't require further checks.
653 Label non_smi_value;
654 __ JumpIfNotSmi(value, &non_smi_value);
655
656 if (increment_length == kIncrementLength) {
657 // Add 1 to receiver->length.
658 __ Addu(scratch_value, key, Operand(Smi::FromInt(1)));
659 __ sw(scratch_value, FieldMemOperand(receiver, JSArray::kLengthOffset));
660 }
661 // It's irrelevant whether array is smi-only or not when writing a smi.
662 __ Addu(address, elements, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
663 __ sll(scratch_value, key, kPointerSizeLog2 - kSmiTagSize);
664 __ Addu(address, address, scratch_value);
665 __ sw(value, MemOperand(address));
666 __ Ret();
667
668 __ bind(&non_smi_value);
669 // Escape to elements kind transition case.
670 __ CheckFastObjectElements(receiver_map, scratch_value,
671 &transition_smi_elements);
672
673 // Fast elements array, store the value to the elements backing store.
674 __ bind(&finish_object_store);
675 if (increment_length == kIncrementLength) {
676 // Add 1 to receiver->length.
677 __ Addu(scratch_value, key, Operand(Smi::FromInt(1)));
678 __ sw(scratch_value, FieldMemOperand(receiver, JSArray::kLengthOffset));
679 }
680 __ Addu(address, elements, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
681 __ sll(scratch_value, key, kPointerSizeLog2 - kSmiTagSize);
682 __ Addu(address, address, scratch_value);
683 __ sw(value, MemOperand(address));
684 // Update write barrier for the elements array address.
685 __ mov(scratch_value, value); // Preserve the value which is returned.
686 __ RecordWrite(elements, address, scratch_value, kRAHasNotBeenSaved,
687 kDontSaveFPRegs, EMIT_REMEMBERED_SET, OMIT_SMI_CHECK);
688 __ Ret();
689
690 __ bind(fast_double);
691 if (check_map == kCheckMap) {
692 // Check for fast double array case. If this fails, call through to the
693 // runtime.
694 __ LoadRoot(at, Heap::kFixedDoubleArrayMapRootIndex);
695 __ Branch(slow, ne, elements_map, Operand(at));
696 }
697
698 // HOLECHECK: guards "A[i] double hole?"
699 // We have to see if the double version of the hole is present. If so
700 // go to the runtime.
701 __ Addu(address, elements, Operand(FixedDoubleArray::kHeaderSize +
702 kHoleNanUpper32Offset - kHeapObjectTag));
703 __ sll(at, key, kPointerSizeLog2);
704 __ addu(address, address, at);
705 __ lw(scratch_value, MemOperand(address));
706 __ Branch(&fast_double_without_map_check, ne, scratch_value,
707 Operand(kHoleNanUpper32));
708 __ JumpIfDictionaryInPrototypeChain(receiver, elements_map, scratch_value,
709 slow);
710
711 __ bind(&fast_double_without_map_check);
712 __ StoreNumberToDoubleElements(value, key,
713 elements, // Overwritten.
714 a3, // Scratch regs...
715 t0, t1, &transition_double_elements);
716 if (increment_length == kIncrementLength) {
717 // Add 1 to receiver->length.
718 __ Addu(scratch_value, key, Operand(Smi::FromInt(1)));
719 __ sw(scratch_value, FieldMemOperand(receiver, JSArray::kLengthOffset));
720 }
721 __ Ret();
722
723 __ bind(&transition_smi_elements);
724 // Transition the array appropriately depending on the value type.
725 __ lw(t0, FieldMemOperand(value, HeapObject::kMapOffset));
726 __ LoadRoot(at, Heap::kHeapNumberMapRootIndex);
727 __ Branch(&non_double_value, ne, t0, Operand(at));
728
729 // Value is a double. Transition FAST_SMI_ELEMENTS ->
730 // FAST_DOUBLE_ELEMENTS and complete the store.
731 __ LoadTransitionedArrayMapConditional(
732 FAST_SMI_ELEMENTS, FAST_DOUBLE_ELEMENTS, receiver_map, t0, slow);
733 AllocationSiteMode mode =
734 AllocationSite::GetMode(FAST_SMI_ELEMENTS, FAST_DOUBLE_ELEMENTS);
735 ElementsTransitionGenerator::GenerateSmiToDouble(masm, receiver, key, value,
736 receiver_map, mode, slow);
737 __ lw(elements, FieldMemOperand(receiver, JSObject::kElementsOffset));
738 __ jmp(&fast_double_without_map_check);
739
740 __ bind(&non_double_value);
741 // Value is not a double, FAST_SMI_ELEMENTS -> FAST_ELEMENTS
742 __ LoadTransitionedArrayMapConditional(FAST_SMI_ELEMENTS, FAST_ELEMENTS,
743 receiver_map, t0, slow);
744 mode = AllocationSite::GetMode(FAST_SMI_ELEMENTS, FAST_ELEMENTS);
745 ElementsTransitionGenerator::GenerateMapChangeElementsTransition(
746 masm, receiver, key, value, receiver_map, mode, slow);
747 __ lw(elements, FieldMemOperand(receiver, JSObject::kElementsOffset));
748 __ jmp(&finish_object_store);
749
750 __ bind(&transition_double_elements);
751 // Elements are FAST_DOUBLE_ELEMENTS, but value is an Object that's not a
752 // HeapNumber. Make sure that the receiver is a Array with FAST_ELEMENTS and
753 // transition array from FAST_DOUBLE_ELEMENTS to FAST_ELEMENTS
754 __ LoadTransitionedArrayMapConditional(FAST_DOUBLE_ELEMENTS, FAST_ELEMENTS,
755 receiver_map, t0, slow);
756 mode = AllocationSite::GetMode(FAST_DOUBLE_ELEMENTS, FAST_ELEMENTS);
757 ElementsTransitionGenerator::GenerateDoubleToObject(
758 masm, receiver, key, value, receiver_map, mode, slow);
759 __ lw(elements, FieldMemOperand(receiver, JSObject::kElementsOffset));
760 __ jmp(&finish_object_store);
761}
762
763
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400764void KeyedStoreIC::GenerateMegamorphic(MacroAssembler* masm,
765 StrictMode strict_mode) {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000766 // ---------- S t a t e --------------
767 // -- a0 : value
768 // -- a1 : key
769 // -- a2 : receiver
770 // -- ra : return address
771 // -----------------------------------
772 Label slow, fast_object, fast_object_grow;
773 Label fast_double, fast_double_grow;
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400774 Label array, extra, check_if_double_array, maybe_name_key, miss;
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000775
776 // Register usage.
777 Register value = StoreDescriptor::ValueRegister();
778 Register key = StoreDescriptor::NameRegister();
779 Register receiver = StoreDescriptor::ReceiverRegister();
780 DCHECK(value.is(a0));
781 Register receiver_map = a3;
782 Register elements_map = t2;
783 Register elements = t3; // Elements array of the receiver.
784 // t0 and t1 are used as general scratch registers.
785
786 // Check that the key is a smi.
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400787 __ JumpIfNotSmi(key, &maybe_name_key);
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000788 // Check that the object isn't a smi.
789 __ JumpIfSmi(receiver, &slow);
790 // Get the map of the object.
791 __ lw(receiver_map, FieldMemOperand(receiver, HeapObject::kMapOffset));
792 // Check that the receiver does not require access checks and is not observed.
793 // The generic stub does not perform map checks or handle observed objects.
794 __ lbu(t0, FieldMemOperand(receiver_map, Map::kBitFieldOffset));
795 __ And(t0, t0,
796 Operand(1 << Map::kIsAccessCheckNeeded | 1 << Map::kIsObserved));
797 __ Branch(&slow, ne, t0, Operand(zero_reg));
798 // Check if the object is a JS array or not.
799 __ lbu(t0, FieldMemOperand(receiver_map, Map::kInstanceTypeOffset));
800 __ Branch(&array, eq, t0, Operand(JS_ARRAY_TYPE));
801 // Check that the object is some kind of JSObject.
802 __ Branch(&slow, lt, t0, Operand(FIRST_JS_OBJECT_TYPE));
803
804 // Object case: Check key against length in the elements array.
805 __ lw(elements, FieldMemOperand(receiver, JSObject::kElementsOffset));
806 // Check array bounds. Both the key and the length of FixedArray are smis.
807 __ lw(t0, FieldMemOperand(elements, FixedArray::kLengthOffset));
808 __ Branch(&fast_object, lo, key, Operand(t0));
809
810 // Slow case, handle jump to runtime.
811 __ bind(&slow);
812 // Entry registers are intact.
813 // a0: value.
814 // a1: key.
815 // a2: receiver.
816 PropertyICCompiler::GenerateRuntimeSetProperty(masm, strict_mode);
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400817 // Never returns to here.
818
819 __ bind(&maybe_name_key);
820 __ lw(t0, FieldMemOperand(key, HeapObject::kMapOffset));
821 __ lb(t0, FieldMemOperand(t0, Map::kInstanceTypeOffset));
822 __ JumpIfNotUniqueNameInstanceType(t0, &slow);
823 Code::Flags flags = Code::RemoveTypeAndHolderFromFlags(
824 Code::ComputeHandlerFlags(Code::STORE_IC));
825 masm->isolate()->stub_cache()->GenerateProbe(
826 masm, Code::STORE_IC, flags, false, receiver, key, a3, t0, t1, t2);
827 // Cache miss.
828 __ Branch(&miss);
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000829
830 // Extra capacity case: Check if there is extra capacity to
831 // perform the store and update the length. Used for adding one
832 // element to the array by writing to array[array.length].
833 __ bind(&extra);
834 // Condition code from comparing key and array length is still available.
835 // Only support writing to array[array.length].
836 __ Branch(&slow, ne, key, Operand(t0));
837 // Check for room in the elements backing store.
838 // Both the key and the length of FixedArray are smis.
839 __ lw(t0, FieldMemOperand(elements, FixedArray::kLengthOffset));
840 __ Branch(&slow, hs, key, Operand(t0));
841 __ lw(elements_map, FieldMemOperand(elements, HeapObject::kMapOffset));
842 __ Branch(&check_if_double_array, ne, elements_map,
843 Heap::kFixedArrayMapRootIndex);
844
845 __ jmp(&fast_object_grow);
846
847 __ bind(&check_if_double_array);
848 __ Branch(&slow, ne, elements_map, Heap::kFixedDoubleArrayMapRootIndex);
849 __ jmp(&fast_double_grow);
850
851 // Array case: Get the length and the elements array from the JS
852 // array. Check that the array is in fast mode (and writable); if it
853 // is the length is always a smi.
854 __ bind(&array);
855 __ lw(elements, FieldMemOperand(receiver, JSObject::kElementsOffset));
856
857 // Check the key against the length in the array.
858 __ lw(t0, FieldMemOperand(receiver, JSArray::kLengthOffset));
859 __ Branch(&extra, hs, key, Operand(t0));
860
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400861 KeyedStoreGenerateMegamorphicHelper(
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000862 masm, &fast_object, &fast_double, &slow, kCheckMap, kDontIncrementLength,
863 value, key, receiver, receiver_map, elements_map, elements);
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400864 KeyedStoreGenerateMegamorphicHelper(masm, &fast_object_grow,
865 &fast_double_grow, &slow, kDontCheckMap,
866 kIncrementLength, value, key, receiver,
867 receiver_map, elements_map, elements);
868
869 __ bind(&miss);
870 GenerateMiss(masm);
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000871}
872
873
874void KeyedStoreIC::GenerateMiss(MacroAssembler* masm) {
875 // Push receiver, key and value for runtime call.
876 __ Push(StoreDescriptor::ReceiverRegister(), StoreDescriptor::NameRegister(),
877 StoreDescriptor::ValueRegister());
878
879 ExternalReference ref =
880 ExternalReference(IC_Utility(kKeyedStoreIC_Miss), masm->isolate());
881 __ TailCallExternalReference(ref, 3, 1);
882}
883
884
885void StoreIC::GenerateMegamorphic(MacroAssembler* masm) {
886 Register receiver = StoreDescriptor::ReceiverRegister();
887 Register name = StoreDescriptor::NameRegister();
888 DCHECK(receiver.is(a1));
889 DCHECK(name.is(a2));
890 DCHECK(StoreDescriptor::ValueRegister().is(a0));
891
892 // Get the receiver from the stack and probe the stub cache.
893 Code::Flags flags = Code::RemoveTypeAndHolderFromFlags(
894 Code::ComputeHandlerFlags(Code::STORE_IC));
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400895 masm->isolate()->stub_cache()->GenerateProbe(
896 masm, Code::STORE_IC, flags, false, receiver, name, a3, t0, t1, t2);
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000897
898 // Cache miss: Jump to runtime.
899 GenerateMiss(masm);
900}
901
902
903void StoreIC::GenerateMiss(MacroAssembler* masm) {
904 __ Push(StoreDescriptor::ReceiverRegister(), StoreDescriptor::NameRegister(),
905 StoreDescriptor::ValueRegister());
906 // Perform tail call to the entry.
907 ExternalReference ref =
908 ExternalReference(IC_Utility(kStoreIC_Miss), masm->isolate());
909 __ TailCallExternalReference(ref, 3, 1);
910}
911
912
913void StoreIC::GenerateNormal(MacroAssembler* masm) {
914 Label miss;
915 Register receiver = StoreDescriptor::ReceiverRegister();
916 Register name = StoreDescriptor::NameRegister();
917 Register value = StoreDescriptor::ValueRegister();
918 Register dictionary = a3;
919 DCHECK(receiver.is(a1));
920 DCHECK(name.is(a2));
921 DCHECK(value.is(a0));
922
923 __ lw(dictionary, FieldMemOperand(receiver, JSObject::kPropertiesOffset));
924
925 GenerateDictionaryStore(masm, &miss, dictionary, name, value, t0, t1);
926 Counters* counters = masm->isolate()->counters();
927 __ IncrementCounter(counters->store_normal_hit(), 1, t0, t1);
928 __ Ret();
929
930 __ bind(&miss);
931 __ IncrementCounter(counters->store_normal_miss(), 1, t0, t1);
932 GenerateMiss(masm);
933}
934
935
936#undef __
937
938
939Condition CompareIC::ComputeCondition(Token::Value op) {
940 switch (op) {
941 case Token::EQ_STRICT:
942 case Token::EQ:
943 return eq;
944 case Token::LT:
945 return lt;
946 case Token::GT:
947 return gt;
948 case Token::LTE:
949 return le;
950 case Token::GTE:
951 return ge;
952 default:
953 UNREACHABLE();
954 return kNoCondition;
955 }
956}
957
958
959bool CompareIC::HasInlinedSmiCode(Address address) {
960 // The address of the instruction following the call.
961 Address andi_instruction_address =
962 address + Assembler::kCallTargetAddressOffset;
963
964 // If the instruction following the call is not a andi at, rx, #yyy, nothing
965 // was inlined.
966 Instr instr = Assembler::instr_at(andi_instruction_address);
967 return Assembler::IsAndImmediate(instr) &&
968 Assembler::GetRt(instr) == static_cast<uint32_t>(zero_reg.code());
969}
970
971
972void PatchInlinedSmiCode(Address address, InlinedSmiCheck check) {
973 Address andi_instruction_address =
974 address + Assembler::kCallTargetAddressOffset;
975
976 // If the instruction following the call is not a andi at, rx, #yyy, nothing
977 // was inlined.
978 Instr instr = Assembler::instr_at(andi_instruction_address);
979 if (!(Assembler::IsAndImmediate(instr) &&
980 Assembler::GetRt(instr) == static_cast<uint32_t>(zero_reg.code()))) {
981 return;
982 }
983
984 // The delta to the start of the map check instruction and the
985 // condition code uses at the patched jump.
986 int delta = Assembler::GetImmediate16(instr);
987 delta += Assembler::GetRs(instr) * kImm16Mask;
988 // If the delta is 0 the instruction is andi at, zero_reg, #0 which also
989 // signals that nothing was inlined.
990 if (delta == 0) {
991 return;
992 }
993
994 if (FLAG_trace_ic) {
995 PrintF("[ patching ic at %p, andi=%p, delta=%d\n", address,
996 andi_instruction_address, delta);
997 }
998
999 Address patch_address =
1000 andi_instruction_address - delta * Instruction::kInstrSize;
1001 Instr instr_at_patch = Assembler::instr_at(patch_address);
1002 Instr branch_instr =
1003 Assembler::instr_at(patch_address + Instruction::kInstrSize);
1004 // This is patching a conditional "jump if not smi/jump if smi" site.
1005 // Enabling by changing from
1006 // andi at, rx, 0
1007 // Branch <target>, eq, at, Operand(zero_reg)
1008 // to:
1009 // andi at, rx, #kSmiTagMask
1010 // Branch <target>, ne, at, Operand(zero_reg)
1011 // and vice-versa to be disabled again.
1012 CodePatcher patcher(patch_address, 2);
1013 Register reg = Register::from_code(Assembler::GetRs(instr_at_patch));
1014 if (check == ENABLE_INLINED_SMI_CHECK) {
1015 DCHECK(Assembler::IsAndImmediate(instr_at_patch));
1016 DCHECK_EQ(0, Assembler::GetImmediate16(instr_at_patch));
1017 patcher.masm()->andi(at, reg, kSmiTagMask);
1018 } else {
1019 DCHECK(check == DISABLE_INLINED_SMI_CHECK);
1020 DCHECK(Assembler::IsAndImmediate(instr_at_patch));
1021 patcher.masm()->andi(at, reg, 0);
1022 }
1023 DCHECK(Assembler::IsBranch(branch_instr));
1024 if (Assembler::IsBeq(branch_instr)) {
1025 patcher.ChangeBranchCondition(ne);
1026 } else {
1027 DCHECK(Assembler::IsBne(branch_instr));
1028 patcher.ChangeBranchCondition(eq);
1029 }
1030}
1031}
1032} // namespace v8::internal
1033
1034#endif // V8_TARGET_ARCH_MIPS