OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 3323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3334 sw(filler, MemOperand(start_offset)); | 3334 sw(filler, MemOperand(start_offset)); |
3335 Addu(start_offset, start_offset, kPointerSize); | 3335 Addu(start_offset, start_offset, kPointerSize); |
3336 bind(&entry); | 3336 bind(&entry); |
3337 Branch(&loop, lt, start_offset, Operand(end_offset)); | 3337 Branch(&loop, lt, start_offset, Operand(end_offset)); |
3338 } | 3338 } |
3339 | 3339 |
3340 | 3340 |
3341 void MacroAssembler::CheckFastElements(Register map, | 3341 void MacroAssembler::CheckFastElements(Register map, |
3342 Register scratch, | 3342 Register scratch, |
3343 Label* fail) { | 3343 Label* fail) { |
3344 STATIC_ASSERT(FAST_SMI_ELEMENTS == 0); | 3344 STATIC_ASSERT(FAST_SMI_ONLY_ELEMENTS == 0); |
3345 STATIC_ASSERT(FAST_HOLEY_SMI_ELEMENTS == 1); | 3345 STATIC_ASSERT(FAST_ELEMENTS == 1); |
3346 STATIC_ASSERT(FAST_ELEMENTS == 2); | |
3347 STATIC_ASSERT(FAST_HOLEY_ELEMENTS == 3); | |
3348 lbu(scratch, FieldMemOperand(map, Map::kBitField2Offset)); | 3346 lbu(scratch, FieldMemOperand(map, Map::kBitField2Offset)); |
3349 Branch(fail, hi, scratch, | 3347 Branch(fail, hi, scratch, Operand(Map::kMaximumBitField2FastElementValue)); |
3350 Operand(Map::kMaximumBitField2FastHoleyElementValue)); | |
3351 } | 3348 } |
3352 | 3349 |
3353 | 3350 |
3354 void MacroAssembler::CheckFastObjectElements(Register map, | 3351 void MacroAssembler::CheckFastObjectElements(Register map, |
3355 Register scratch, | 3352 Register scratch, |
3356 Label* fail) { | 3353 Label* fail) { |
3357 STATIC_ASSERT(FAST_SMI_ELEMENTS == 0); | 3354 STATIC_ASSERT(FAST_SMI_ONLY_ELEMENTS == 0); |
3358 STATIC_ASSERT(FAST_HOLEY_SMI_ELEMENTS == 1); | 3355 STATIC_ASSERT(FAST_ELEMENTS == 1); |
3359 STATIC_ASSERT(FAST_ELEMENTS == 2); | |
3360 STATIC_ASSERT(FAST_HOLEY_ELEMENTS == 3); | |
3361 lbu(scratch, FieldMemOperand(map, Map::kBitField2Offset)); | 3356 lbu(scratch, FieldMemOperand(map, Map::kBitField2Offset)); |
3362 Branch(fail, ls, scratch, | 3357 Branch(fail, ls, scratch, |
3363 Operand(Map::kMaximumBitField2FastHoleySmiElementValue)); | 3358 Operand(Map::kMaximumBitField2FastSmiOnlyElementValue)); |
3364 Branch(fail, hi, scratch, | 3359 Branch(fail, hi, scratch, |
3365 Operand(Map::kMaximumBitField2FastHoleyElementValue)); | 3360 Operand(Map::kMaximumBitField2FastElementValue)); |
3366 } | 3361 } |
3367 | 3362 |
3368 | 3363 |
3369 void MacroAssembler::CheckFastSmiElements(Register map, | 3364 void MacroAssembler::CheckFastSmiOnlyElements(Register map, |
3370 Register scratch, | 3365 Register scratch, |
3371 Label* fail) { | 3366 Label* fail) { |
3372 STATIC_ASSERT(FAST_SMI_ELEMENTS == 0); | 3367 STATIC_ASSERT(FAST_SMI_ONLY_ELEMENTS == 0); |
3373 STATIC_ASSERT(FAST_HOLEY_SMI_ELEMENTS == 1); | |
3374 lbu(scratch, FieldMemOperand(map, Map::kBitField2Offset)); | 3368 lbu(scratch, FieldMemOperand(map, Map::kBitField2Offset)); |
3375 Branch(fail, hi, scratch, | 3369 Branch(fail, hi, scratch, |
3376 Operand(Map::kMaximumBitField2FastHoleySmiElementValue)); | 3370 Operand(Map::kMaximumBitField2FastSmiOnlyElementValue)); |
3377 } | 3371 } |
3378 | 3372 |
3379 | 3373 |
3380 void MacroAssembler::StoreNumberToDoubleElements(Register value_reg, | 3374 void MacroAssembler::StoreNumberToDoubleElements(Register value_reg, |
3381 Register key_reg, | 3375 Register key_reg, |
3382 Register receiver_reg, | 3376 Register receiver_reg, |
3383 Register elements_reg, | 3377 Register elements_reg, |
3384 Register scratch1, | 3378 Register scratch1, |
3385 Register scratch2, | 3379 Register scratch2, |
3386 Register scratch3, | 3380 Register scratch3, |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3468 void MacroAssembler::CompareMapAndBranch(Register obj, | 3462 void MacroAssembler::CompareMapAndBranch(Register obj, |
3469 Register scratch, | 3463 Register scratch, |
3470 Handle<Map> map, | 3464 Handle<Map> map, |
3471 Label* early_success, | 3465 Label* early_success, |
3472 Condition cond, | 3466 Condition cond, |
3473 Label* branch_to, | 3467 Label* branch_to, |
3474 CompareMapMode mode) { | 3468 CompareMapMode mode) { |
3475 lw(scratch, FieldMemOperand(obj, HeapObject::kMapOffset)); | 3469 lw(scratch, FieldMemOperand(obj, HeapObject::kMapOffset)); |
3476 Operand right = Operand(map); | 3470 Operand right = Operand(map); |
3477 if (mode == ALLOW_ELEMENT_TRANSITION_MAPS) { | 3471 if (mode == ALLOW_ELEMENT_TRANSITION_MAPS) { |
3478 ElementsKind kind = map->elements_kind(); | 3472 Map* transitioned_fast_element_map( |
3479 if (IsFastElementsKind(kind)) { | 3473 map->LookupElementsTransitionMap(FAST_ELEMENTS, NULL)); |
3480 bool packed = IsFastPackedElementsKind(kind); | 3474 ASSERT(transitioned_fast_element_map == NULL || |
3481 Map* current_map = *map; | 3475 map->elements_kind() != FAST_ELEMENTS); |
3482 while (CanTransitionToMoreGeneralFastElementsKind(kind, packed)) { | 3476 if (transitioned_fast_element_map != NULL) { |
3483 kind = GetNextMoreGeneralFastElementsKind(kind, packed); | 3477 Branch(early_success, eq, scratch, right); |
3484 current_map = current_map->LookupElementsTransitionMap(kind, NULL); | 3478 right = Operand(Handle<Map>(transitioned_fast_element_map)); |
3485 if (!current_map) break; | 3479 } |
3486 Branch(early_success, eq, scratch, right); | 3480 |
3487 right = Operand(Handle<Map>(current_map)); | 3481 Map* transitioned_double_map( |
3488 } | 3482 map->LookupElementsTransitionMap(FAST_DOUBLE_ELEMENTS, NULL)); |
| 3483 ASSERT(transitioned_double_map == NULL || |
| 3484 map->elements_kind() == FAST_SMI_ONLY_ELEMENTS); |
| 3485 if (transitioned_double_map != NULL) { |
| 3486 Branch(early_success, eq, scratch, right); |
| 3487 right = Operand(Handle<Map>(transitioned_double_map)); |
3489 } | 3488 } |
3490 } | 3489 } |
3491 | 3490 |
3492 Branch(branch_to, cond, scratch, right); | 3491 Branch(branch_to, cond, scratch, right); |
3493 } | 3492 } |
3494 | 3493 |
3495 | 3494 |
3496 void MacroAssembler::CheckMap(Register obj, | 3495 void MacroAssembler::CheckMap(Register obj, |
3497 Register scratch, | 3496 Register scratch, |
3498 Handle<Map> map, | 3497 Handle<Map> map, |
(...skipping 938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4437 ElementsKind expected_kind, | 4436 ElementsKind expected_kind, |
4438 ElementsKind transitioned_kind, | 4437 ElementsKind transitioned_kind, |
4439 Register map_in_out, | 4438 Register map_in_out, |
4440 Register scratch, | 4439 Register scratch, |
4441 Label* no_map_match) { | 4440 Label* no_map_match) { |
4442 // Load the global or builtins object from the current context. | 4441 // Load the global or builtins object from the current context. |
4443 lw(scratch, MemOperand(cp, Context::SlotOffset(Context::GLOBAL_INDEX))); | 4442 lw(scratch, MemOperand(cp, Context::SlotOffset(Context::GLOBAL_INDEX))); |
4444 lw(scratch, FieldMemOperand(scratch, GlobalObject::kGlobalContextOffset)); | 4443 lw(scratch, FieldMemOperand(scratch, GlobalObject::kGlobalContextOffset)); |
4445 | 4444 |
4446 // Check that the function's map is the same as the expected cached map. | 4445 // Check that the function's map is the same as the expected cached map. |
4447 lw(scratch, | 4446 int expected_index = |
4448 MemOperand(scratch, | 4447 Context::GetContextMapIndexFromElementsKind(expected_kind); |
4449 Context::SlotOffset(Context::JS_ARRAY_MAPS_INDEX))); | 4448 lw(at, MemOperand(scratch, Context::SlotOffset(expected_index))); |
4450 size_t offset = expected_kind * kPointerSize + | 4449 Branch(no_map_match, ne, map_in_out, Operand(at)); |
4451 FixedArrayBase::kHeaderSize; | |
4452 Branch(no_map_match, ne, map_in_out, Operand(scratch)); | |
4453 | 4450 |
4454 // Use the transitioned cached map. | 4451 // Use the transitioned cached map. |
4455 offset = transitioned_kind * kPointerSize + | 4452 int trans_index = |
4456 FixedArrayBase::kHeaderSize; | 4453 Context::GetContextMapIndexFromElementsKind(transitioned_kind); |
4457 lw(map_in_out, FieldMemOperand(scratch, offset)); | 4454 lw(map_in_out, MemOperand(scratch, Context::SlotOffset(trans_index))); |
4458 } | 4455 } |
4459 | 4456 |
4460 | 4457 |
4461 void MacroAssembler::LoadInitialArrayMap( | 4458 void MacroAssembler::LoadInitialArrayMap( |
4462 Register function_in, Register scratch, | 4459 Register function_in, Register scratch, Register map_out) { |
4463 Register map_out, bool can_have_holes) { | |
4464 ASSERT(!function_in.is(map_out)); | 4460 ASSERT(!function_in.is(map_out)); |
4465 Label done; | 4461 Label done; |
4466 lw(map_out, FieldMemOperand(function_in, | 4462 lw(map_out, FieldMemOperand(function_in, |
4467 JSFunction::kPrototypeOrInitialMapOffset)); | 4463 JSFunction::kPrototypeOrInitialMapOffset)); |
4468 if (!FLAG_smi_only_arrays) { | 4464 if (!FLAG_smi_only_arrays) { |
4469 ElementsKind kind = can_have_holes ? FAST_HOLEY_ELEMENTS : FAST_ELEMENTS; | 4465 LoadTransitionedArrayMapConditional(FAST_SMI_ONLY_ELEMENTS, |
4470 LoadTransitionedArrayMapConditional(FAST_SMI_ELEMENTS, | 4466 FAST_ELEMENTS, |
4471 kind, | |
4472 map_out, | 4467 map_out, |
4473 scratch, | 4468 scratch, |
4474 &done); | 4469 &done); |
4475 } else if (can_have_holes) { | |
4476 LoadTransitionedArrayMapConditional(FAST_SMI_ELEMENTS, | |
4477 FAST_HOLEY_SMI_ELEMENTS, | |
4478 map_out, | |
4479 scratch, | |
4480 &done); | |
4481 } | 4470 } |
4482 bind(&done); | 4471 bind(&done); |
4483 } | 4472 } |
4484 | 4473 |
4485 | 4474 |
4486 void MacroAssembler::LoadGlobalFunction(int index, Register function) { | 4475 void MacroAssembler::LoadGlobalFunction(int index, Register function) { |
4487 // Load the global or builtins object from the current context. | 4476 // Load the global or builtins object from the current context. |
4488 lw(function, MemOperand(cp, Context::SlotOffset(Context::GLOBAL_INDEX))); | 4477 lw(function, MemOperand(cp, Context::SlotOffset(Context::GLOBAL_INDEX))); |
4489 // Load the global context from the global or builtins object. | 4478 // Load the global context from the global or builtins object. |
4490 lw(function, FieldMemOperand(function, | 4479 lw(function, FieldMemOperand(function, |
(...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5435 opcode == BGTZL); | 5424 opcode == BGTZL); |
5436 opcode = (cond == eq) ? BEQ : BNE; | 5425 opcode = (cond == eq) ? BEQ : BNE; |
5437 instr = (instr & ~kOpcodeMask) | opcode; | 5426 instr = (instr & ~kOpcodeMask) | opcode; |
5438 masm_.emit(instr); | 5427 masm_.emit(instr); |
5439 } | 5428 } |
5440 | 5429 |
5441 | 5430 |
5442 } } // namespace v8::internal | 5431 } } // namespace v8::internal |
5443 | 5432 |
5444 #endif // V8_TARGET_ARCH_MIPS | 5433 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |