Chromium Code Reviews| 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 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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::kMaximumBitField2FastHoleySmiOnlyElementValue); |
| 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::CheckFastSmiOnlyElements(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::kMaximumBitField2FastHoleySmiOnlyElementValue); |
| 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 Loading... | |
| 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 = |
|
Jakob Kummerow
2012/05/13 21:55:27
nit: fits on one line?
danno
2012/05/22 11:05:21
Done.
| |
| 503 Handle<Map>(transitioned_fast_element_map)); | 508 current_map->LookupElementsTransitionMap(kind, NULL); |
| 504 } | 509 if (!current_map) break; |
| 505 | 510 j(equal, early_success, Label::kNear); |
| 506 Map* transitioned_double_map( | 511 cmp(FieldOperand(obj, HeapObject::kMapOffset), |
| 507 map->LookupElementsTransitionMap(FAST_DOUBLE_ELEMENTS, NULL)); | 512 Handle<Map>(current_map)); |
| 508 ASSERT(transitioned_double_map == NULL || | 513 } |
| 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 } | 514 } |
| 515 } | 515 } |
| 516 } | 516 } |
| 517 | 517 |
| 518 | 518 |
| 519 void MacroAssembler::CheckMap(Register obj, | 519 void MacroAssembler::CheckMap(Register obj, |
| 520 Handle<Map> map, | 520 Handle<Map> map, |
| 521 Label* fail, | 521 Label* fail, |
| 522 SmiCheckType smi_check_type, | 522 SmiCheckType smi_check_type, |
| 523 CompareMapMode mode) { | 523 CompareMapMode mode) { |
| (...skipping 1630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2154 ElementsKind expected_kind, | 2154 ElementsKind expected_kind, |
| 2155 ElementsKind transitioned_kind, | 2155 ElementsKind transitioned_kind, |
| 2156 Register map_in_out, | 2156 Register map_in_out, |
| 2157 Register scratch, | 2157 Register scratch, |
| 2158 Label* no_map_match) { | 2158 Label* no_map_match) { |
| 2159 // Load the global or builtins object from the current context. | 2159 // Load the global or builtins object from the current context. |
| 2160 mov(scratch, Operand(esi, Context::SlotOffset(Context::GLOBAL_INDEX))); | 2160 mov(scratch, Operand(esi, Context::SlotOffset(Context::GLOBAL_INDEX))); |
| 2161 mov(scratch, FieldOperand(scratch, GlobalObject::kGlobalContextOffset)); | 2161 mov(scratch, FieldOperand(scratch, GlobalObject::kGlobalContextOffset)); |
| 2162 | 2162 |
| 2163 // Check that the function's map is the same as the expected cached map. | 2163 // Check that the function's map is the same as the expected cached map. |
| 2164 int expected_index = | 2164 mov(scratch, Operand(scratch, |
| 2165 Context::GetContextMapIndexFromElementsKind(expected_kind); | 2165 Context::SlotOffset(Context::JS_ARRAY_MAPS_INDEX))); |
| 2166 cmp(map_in_out, Operand(scratch, Context::SlotOffset(expected_index))); | 2166 |
| 2167 size_t offset = expected_kind * kPointerSize + | |
| 2168 FixedArrayBase::kHeaderSize; | |
| 2169 cmp(map_in_out, FieldOperand(scratch, offset)); | |
| 2167 j(not_equal, no_map_match); | 2170 j(not_equal, no_map_match); |
| 2168 | 2171 |
| 2169 // Use the transitioned cached map. | 2172 // Use the transitioned cached map. |
| 2170 int trans_index = | 2173 offset = transitioned_kind * kPointerSize + |
| 2171 Context::GetContextMapIndexFromElementsKind(transitioned_kind); | 2174 FixedArrayBase::kHeaderSize; |
| 2172 mov(map_in_out, Operand(scratch, Context::SlotOffset(trans_index))); | 2175 mov(map_in_out, FieldOperand(scratch, offset)); |
| 2173 } | 2176 } |
| 2174 | 2177 |
| 2175 | 2178 |
| 2176 void MacroAssembler::LoadInitialArrayMap( | 2179 void MacroAssembler::LoadInitialArrayMap( |
| 2177 Register function_in, Register scratch, Register map_out) { | 2180 Register function_in, Register scratch, |
| 2181 Register map_out, bool can_have_holes) { | |
| 2178 ASSERT(!function_in.is(map_out)); | 2182 ASSERT(!function_in.is(map_out)); |
| 2179 Label done; | 2183 Label done; |
| 2180 mov(map_out, FieldOperand(function_in, | 2184 mov(map_out, FieldOperand(function_in, |
| 2181 JSFunction::kPrototypeOrInitialMapOffset)); | 2185 JSFunction::kPrototypeOrInitialMapOffset)); |
| 2182 if (!FLAG_smi_only_arrays) { | 2186 if (!FLAG_smi_only_arrays) { |
| 2183 LoadTransitionedArrayMapConditional(FAST_SMI_ONLY_ELEMENTS, | 2187 ElementsKind kind = can_have_holes |
| 2184 FAST_ELEMENTS, | 2188 ? FAST_HOLEY_ELEMENTS : |
|
Jakob Kummerow
2012/05/13 21:55:27
nit: I'd put the : under the ?
danno
2012/05/22 11:05:21
Done.
| |
| 2189 FAST_ELEMENTS; | |
| 2190 LoadTransitionedArrayMapConditional(FAST_SMI_ELEMENTS, | |
| 2191 kind, | |
| 2185 map_out, | 2192 map_out, |
| 2186 scratch, | 2193 scratch, |
| 2187 &done); | 2194 &done); |
| 2195 } else if (can_have_holes) { | |
| 2196 LoadTransitionedArrayMapConditional(FAST_SMI_ELEMENTS, | |
| 2197 FAST_HOLEY_SMI_ELEMENTS, | |
| 2198 map_out, | |
| 2199 scratch, | |
| 2200 &done); | |
| 2188 } | 2201 } |
| 2189 bind(&done); | 2202 bind(&done); |
| 2190 } | 2203 } |
| 2191 | 2204 |
| 2192 | 2205 |
| 2193 void MacroAssembler::LoadGlobalFunction(int index, Register function) { | 2206 void MacroAssembler::LoadGlobalFunction(int index, Register function) { |
| 2194 // Load the global or builtins object from the current context. | 2207 // Load the global or builtins object from the current context. |
| 2195 mov(function, Operand(esi, Context::SlotOffset(Context::GLOBAL_INDEX))); | 2208 mov(function, Operand(esi, Context::SlotOffset(Context::GLOBAL_INDEX))); |
| 2196 // Load the global context from the global or builtins object. | 2209 // Load the global context from the global or builtins object. |
| 2197 mov(function, FieldOperand(function, GlobalObject::kGlobalContextOffset)); | 2210 mov(function, FieldOperand(function, GlobalObject::kGlobalContextOffset)); |
| (...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2812 // Load the prototype from the map and loop if non-null. | 2825 // Load the prototype from the map and loop if non-null. |
| 2813 bind(&check_prototype); | 2826 bind(&check_prototype); |
| 2814 mov(ecx, FieldOperand(ebx, Map::kPrototypeOffset)); | 2827 mov(ecx, FieldOperand(ebx, Map::kPrototypeOffset)); |
| 2815 cmp(ecx, isolate()->factory()->null_value()); | 2828 cmp(ecx, isolate()->factory()->null_value()); |
| 2816 j(not_equal, &next); | 2829 j(not_equal, &next); |
| 2817 } | 2830 } |
| 2818 | 2831 |
| 2819 } } // namespace v8::internal | 2832 } } // namespace v8::internal |
| 2820 | 2833 |
| 2821 #endif // V8_TARGET_ARCH_IA32 | 2834 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |