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

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

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

Powered by Google App Engine
This is Rietveld 408576698