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

Side by Side Diff: src/ia32/macro-assembler-ia32.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/ia32/macro-assembler-ia32.h ('k') | src/ia32/stub-cache-ia32.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 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 375
376 void MacroAssembler::CmpInstanceType(Register map, InstanceType type) { 376 void MacroAssembler::CmpInstanceType(Register map, InstanceType type) {
377 cmpb(FieldOperand(map, Map::kInstanceTypeOffset), 377 cmpb(FieldOperand(map, Map::kInstanceTypeOffset),
378 static_cast<int8_t>(type)); 378 static_cast<int8_t>(type));
379 } 379 }
380 380
381 381
382 void MacroAssembler::CheckFastElements(Register map, 382 void MacroAssembler::CheckFastElements(Register map,
383 Label* fail, 383 Label* fail,
384 Label::Distance distance) { 384 Label::Distance distance) {
385 STATIC_ASSERT(FAST_SMI_ONLY_ELEMENTS == 0); 385 STATIC_ASSERT(FAST_SMI_ELEMENTS == 0);
386 STATIC_ASSERT(FAST_ELEMENTS == 1); 386 STATIC_ASSERT(FAST_HOLEY_SMI_ELEMENTS == 1);
387 STATIC_ASSERT(FAST_ELEMENTS == 2);
388 STATIC_ASSERT(FAST_HOLEY_ELEMENTS == 3);
387 cmpb(FieldOperand(map, Map::kBitField2Offset), 389 cmpb(FieldOperand(map, Map::kBitField2Offset),
388 Map::kMaximumBitField2FastElementValue); 390 Map::kMaximumBitField2FastHoleyElementValue);
389 j(above, fail, distance); 391 j(above, fail, distance);
390 } 392 }
391 393
392 394
393 void MacroAssembler::CheckFastObjectElements(Register map, 395 void MacroAssembler::CheckFastObjectElements(Register map,
394 Label* fail, 396 Label* fail,
395 Label::Distance distance) { 397 Label::Distance distance) {
396 STATIC_ASSERT(FAST_SMI_ONLY_ELEMENTS == 0); 398 STATIC_ASSERT(FAST_SMI_ELEMENTS == 0);
397 STATIC_ASSERT(FAST_ELEMENTS == 1); 399 STATIC_ASSERT(FAST_HOLEY_SMI_ELEMENTS == 1);
400 STATIC_ASSERT(FAST_ELEMENTS == 2);
401 STATIC_ASSERT(FAST_HOLEY_ELEMENTS == 3);
398 cmpb(FieldOperand(map, Map::kBitField2Offset), 402 cmpb(FieldOperand(map, Map::kBitField2Offset),
399 Map::kMaximumBitField2FastSmiOnlyElementValue); 403 Map::kMaximumBitField2FastHoleySmiElementValue);
400 j(below_equal, fail, distance); 404 j(below_equal, fail, distance);
401 cmpb(FieldOperand(map, Map::kBitField2Offset), 405 cmpb(FieldOperand(map, Map::kBitField2Offset),
402 Map::kMaximumBitField2FastElementValue); 406 Map::kMaximumBitField2FastHoleyElementValue);
403 j(above, fail, distance); 407 j(above, fail, distance);
404 } 408 }
405 409
406 410
407 void MacroAssembler::CheckFastSmiOnlyElements(Register map, 411 void MacroAssembler::CheckFastSmiElements(Register map,
408 Label* fail, 412 Label* fail,
409 Label::Distance distance) { 413 Label::Distance distance) {
410 STATIC_ASSERT(FAST_SMI_ONLY_ELEMENTS == 0); 414 STATIC_ASSERT(FAST_SMI_ELEMENTS == 0);
415 STATIC_ASSERT(FAST_HOLEY_SMI_ELEMENTS == 1);
411 cmpb(FieldOperand(map, Map::kBitField2Offset), 416 cmpb(FieldOperand(map, Map::kBitField2Offset),
412 Map::kMaximumBitField2FastSmiOnlyElementValue); 417 Map::kMaximumBitField2FastHoleySmiElementValue);
413 j(above, fail, distance); 418 j(above, fail, distance);
414 } 419 }
415 420
416 421
417 void MacroAssembler::StoreNumberToDoubleElements( 422 void MacroAssembler::StoreNumberToDoubleElements(
418 Register maybe_number, 423 Register maybe_number,
419 Register elements, 424 Register elements,
420 Register key, 425 Register key,
421 Register scratch1, 426 Register scratch1,
422 XMMRegister scratch2, 427 XMMRegister scratch2,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 bind(&done); 491 bind(&done);
487 } 492 }
488 493
489 494
490 void MacroAssembler::CompareMap(Register obj, 495 void MacroAssembler::CompareMap(Register obj,
491 Handle<Map> map, 496 Handle<Map> map,
492 Label* early_success, 497 Label* early_success,
493 CompareMapMode mode) { 498 CompareMapMode mode) {
494 cmp(FieldOperand(obj, HeapObject::kMapOffset), map); 499 cmp(FieldOperand(obj, HeapObject::kMapOffset), map);
495 if (mode == ALLOW_ELEMENT_TRANSITION_MAPS) { 500 if (mode == ALLOW_ELEMENT_TRANSITION_MAPS) {
496 Map* transitioned_fast_element_map( 501 ElementsKind kind = map->elements_kind();
497 map->LookupElementsTransitionMap(FAST_ELEMENTS, NULL)); 502 if (IsFastElementsKind(kind)) {
498 ASSERT(transitioned_fast_element_map == NULL || 503 bool packed = IsFastPackedElementsKind(kind);
499 map->elements_kind() != FAST_ELEMENTS); 504 Map* current_map = *map;
500 if (transitioned_fast_element_map != NULL) { 505 while (CanTransitionToMoreGeneralFastElementsKind(kind, packed)) {
501 j(equal, early_success, Label::kNear); 506 kind = GetNextMoreGeneralFastElementsKind(kind, packed);
502 cmp(FieldOperand(obj, HeapObject::kMapOffset), 507 current_map = current_map->LookupElementsTransitionMap(kind, NULL);
503 Handle<Map>(transitioned_fast_element_map)); 508 if (!current_map) break;
504 } 509 j(equal, early_success, Label::kNear);
505 510 cmp(FieldOperand(obj, HeapObject::kMapOffset),
506 Map* transitioned_double_map( 511 Handle<Map>(current_map));
507 map->LookupElementsTransitionMap(FAST_DOUBLE_ELEMENTS, NULL)); 512 }
508 ASSERT(transitioned_double_map == NULL ||
509 map->elements_kind() == FAST_SMI_ONLY_ELEMENTS);
510 if (transitioned_double_map != NULL) {
511 j(equal, early_success, Label::kNear);
512 cmp(FieldOperand(obj, HeapObject::kMapOffset),
513 Handle<Map>(transitioned_double_map));
514 } 513 }
515 } 514 }
516 } 515 }
517 516
518 517
519 void MacroAssembler::CheckMap(Register obj, 518 void MacroAssembler::CheckMap(Register obj,
520 Handle<Map> map, 519 Handle<Map> map,
521 Label* fail, 520 Label* fail,
522 SmiCheckType smi_check_type, 521 SmiCheckType smi_check_type,
523 CompareMapMode mode) { 522 CompareMapMode mode) {
(...skipping 1630 matching lines...) Expand 10 before | Expand all | Expand 10 after
2154 ElementsKind expected_kind, 2153 ElementsKind expected_kind,
2155 ElementsKind transitioned_kind, 2154 ElementsKind transitioned_kind,
2156 Register map_in_out, 2155 Register map_in_out,
2157 Register scratch, 2156 Register scratch,
2158 Label* no_map_match) { 2157 Label* no_map_match) {
2159 // Load the global or builtins object from the current context. 2158 // Load the global or builtins object from the current context.
2160 mov(scratch, Operand(esi, Context::SlotOffset(Context::GLOBAL_INDEX))); 2159 mov(scratch, Operand(esi, Context::SlotOffset(Context::GLOBAL_INDEX)));
2161 mov(scratch, FieldOperand(scratch, GlobalObject::kGlobalContextOffset)); 2160 mov(scratch, FieldOperand(scratch, GlobalObject::kGlobalContextOffset));
2162 2161
2163 // Check that the function's map is the same as the expected cached map. 2162 // Check that the function's map is the same as the expected cached map.
2164 int expected_index = 2163 mov(scratch, Operand(scratch,
2165 Context::GetContextMapIndexFromElementsKind(expected_kind); 2164 Context::SlotOffset(Context::JS_ARRAY_MAPS_INDEX)));
2166 cmp(map_in_out, Operand(scratch, Context::SlotOffset(expected_index))); 2165
2166 size_t offset = expected_kind * kPointerSize +
2167 FixedArrayBase::kHeaderSize;
2168 cmp(map_in_out, FieldOperand(scratch, offset));
2167 j(not_equal, no_map_match); 2169 j(not_equal, no_map_match);
2168 2170
2169 // Use the transitioned cached map. 2171 // Use the transitioned cached map.
2170 int trans_index = 2172 offset = transitioned_kind * kPointerSize +
2171 Context::GetContextMapIndexFromElementsKind(transitioned_kind); 2173 FixedArrayBase::kHeaderSize;
2172 mov(map_in_out, Operand(scratch, Context::SlotOffset(trans_index))); 2174 mov(map_in_out, FieldOperand(scratch, offset));
2173 } 2175 }
2174 2176
2175 2177
2176 void MacroAssembler::LoadInitialArrayMap( 2178 void MacroAssembler::LoadInitialArrayMap(
2177 Register function_in, Register scratch, Register map_out) { 2179 Register function_in, Register scratch,
2180 Register map_out, bool can_have_holes) {
2178 ASSERT(!function_in.is(map_out)); 2181 ASSERT(!function_in.is(map_out));
2179 Label done; 2182 Label done;
2180 mov(map_out, FieldOperand(function_in, 2183 mov(map_out, FieldOperand(function_in,
2181 JSFunction::kPrototypeOrInitialMapOffset)); 2184 JSFunction::kPrototypeOrInitialMapOffset));
2182 if (!FLAG_smi_only_arrays) { 2185 if (!FLAG_smi_only_arrays) {
2183 LoadTransitionedArrayMapConditional(FAST_SMI_ONLY_ELEMENTS, 2186 ElementsKind kind = can_have_holes ? FAST_HOLEY_ELEMENTS : FAST_ELEMENTS;
2184 FAST_ELEMENTS, 2187 LoadTransitionedArrayMapConditional(FAST_SMI_ELEMENTS,
2188 kind,
2185 map_out, 2189 map_out,
2186 scratch, 2190 scratch,
2187 &done); 2191 &done);
2192 } else if (can_have_holes) {
2193 LoadTransitionedArrayMapConditional(FAST_SMI_ELEMENTS,
2194 FAST_HOLEY_SMI_ELEMENTS,
2195 map_out,
2196 scratch,
2197 &done);
2188 } 2198 }
2189 bind(&done); 2199 bind(&done);
2190 } 2200 }
2191 2201
2192 2202
2193 void MacroAssembler::LoadGlobalFunction(int index, Register function) { 2203 void MacroAssembler::LoadGlobalFunction(int index, Register function) {
2194 // Load the global or builtins object from the current context. 2204 // Load the global or builtins object from the current context.
2195 mov(function, Operand(esi, Context::SlotOffset(Context::GLOBAL_INDEX))); 2205 mov(function, Operand(esi, Context::SlotOffset(Context::GLOBAL_INDEX)));
2196 // Load the global context from the global or builtins object. 2206 // Load the global context from the global or builtins object.
2197 mov(function, FieldOperand(function, GlobalObject::kGlobalContextOffset)); 2207 mov(function, FieldOperand(function, GlobalObject::kGlobalContextOffset));
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
2812 // Load the prototype from the map and loop if non-null. 2822 // Load the prototype from the map and loop if non-null.
2813 bind(&check_prototype); 2823 bind(&check_prototype);
2814 mov(ecx, FieldOperand(ebx, Map::kPrototypeOffset)); 2824 mov(ecx, FieldOperand(ebx, Map::kPrototypeOffset));
2815 cmp(ecx, isolate()->factory()->null_value()); 2825 cmp(ecx, isolate()->factory()->null_value());
2816 j(not_equal, &next); 2826 j(not_equal, &next);
2817 } 2827 }
2818 2828
2819 } } // namespace v8::internal 2829 } } // namespace v8::internal
2820 2830
2821 #endif // V8_TARGET_ARCH_IA32 2831 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/macro-assembler-ia32.h ('k') | src/ia32/stub-cache-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698