| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 } | 180 } |
| 181 | 181 |
| 182 | 182 |
| 183 static void InitializeArrayConstructorDescriptor( | 183 static void InitializeArrayConstructorDescriptor( |
| 184 Isolate* isolate, | 184 Isolate* isolate, |
| 185 CodeStubInterfaceDescriptor* descriptor, | 185 CodeStubInterfaceDescriptor* descriptor, |
| 186 int constant_stack_parameter_count) { | 186 int constant_stack_parameter_count) { |
| 187 // register state | 187 // register state |
| 188 // rax -- number of arguments | 188 // rax -- number of arguments |
| 189 // rdi -- function | 189 // rdi -- function |
| 190 // rbx -- type info cell with elements kind | 190 // rbx -- allocation site with elements kind |
| 191 static Register registers_variable_args[] = { rdi, rbx, rax }; | 191 static Register registers_variable_args[] = { rdi, rbx, rax }; |
| 192 static Register registers_no_args[] = { rdi, rbx }; | 192 static Register registers_no_args[] = { rdi, rbx }; |
| 193 | 193 |
| 194 if (constant_stack_parameter_count == 0) { | 194 if (constant_stack_parameter_count == 0) { |
| 195 descriptor->register_param_count_ = 2; | 195 descriptor->register_param_count_ = 2; |
| 196 descriptor->register_params_ = registers_no_args; | 196 descriptor->register_params_ = registers_no_args; |
| 197 } else { | 197 } else { |
| 198 // stack param count needs (constructor pointer, and single argument) | 198 // stack param count needs (constructor pointer, and single argument) |
| 199 descriptor->handler_arguments_mode_ = PASS_ARGUMENTS; | 199 descriptor->handler_arguments_mode_ = PASS_ARGUMENTS; |
| 200 descriptor->stack_parameter_count_ = rax; | 200 descriptor->stack_parameter_count_ = rax; |
| (...skipping 5024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5225 // If we reached this point there is a problem. | 5225 // If we reached this point there is a problem. |
| 5226 __ Abort(kUnexpectedElementsKindInArrayConstructor); | 5226 __ Abort(kUnexpectedElementsKindInArrayConstructor); |
| 5227 } else { | 5227 } else { |
| 5228 UNREACHABLE(); | 5228 UNREACHABLE(); |
| 5229 } | 5229 } |
| 5230 } | 5230 } |
| 5231 | 5231 |
| 5232 | 5232 |
| 5233 static void CreateArrayDispatchOneArgument(MacroAssembler* masm, | 5233 static void CreateArrayDispatchOneArgument(MacroAssembler* masm, |
| 5234 AllocationSiteOverrideMode mode) { | 5234 AllocationSiteOverrideMode mode) { |
| 5235 // rbx - type info cell (if mode != DISABLE_ALLOCATION_SITES) | 5235 // rbx - allocation site (if mode != DISABLE_ALLOCATION_SITES) |
| 5236 // rdx - kind (if mode != DISABLE_ALLOCATION_SITES) | 5236 // rdx - kind (if mode != DISABLE_ALLOCATION_SITES) |
| 5237 // rax - number of arguments | 5237 // rax - number of arguments |
| 5238 // rdi - constructor? | 5238 // rdi - constructor? |
| 5239 // rsp[0] - return address | 5239 // rsp[0] - return address |
| 5240 // rsp[8] - last argument | 5240 // rsp[8] - last argument |
| 5241 Handle<Object> undefined_sentinel( | 5241 Handle<Object> undefined_sentinel( |
| 5242 masm->isolate()->heap()->undefined_value(), | 5242 masm->isolate()->heap()->undefined_value(), |
| 5243 masm->isolate()); | 5243 masm->isolate()); |
| 5244 | 5244 |
| 5245 Label normal_sequence; | 5245 Label normal_sequence; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 5271 __ TailCallStub(&stub_holey); | 5271 __ TailCallStub(&stub_holey); |
| 5272 | 5272 |
| 5273 __ bind(&normal_sequence); | 5273 __ bind(&normal_sequence); |
| 5274 ArraySingleArgumentConstructorStub stub(initial, | 5274 ArraySingleArgumentConstructorStub stub(initial, |
| 5275 DISABLE_ALLOCATION_SITES); | 5275 DISABLE_ALLOCATION_SITES); |
| 5276 __ TailCallStub(&stub); | 5276 __ TailCallStub(&stub); |
| 5277 } else if (mode == DONT_OVERRIDE) { | 5277 } else if (mode == DONT_OVERRIDE) { |
| 5278 // We are going to create a holey array, but our kind is non-holey. | 5278 // We are going to create a holey array, but our kind is non-holey. |
| 5279 // Fix kind and retry (only if we have an allocation site in the cell). | 5279 // Fix kind and retry (only if we have an allocation site in the cell). |
| 5280 __ incl(rdx); | 5280 __ incl(rdx); |
| 5281 __ movp(rcx, FieldOperand(rbx, Cell::kValueOffset)); | 5281 |
| 5282 if (FLAG_debug_code) { | 5282 if (FLAG_debug_code) { |
| 5283 Handle<Map> allocation_site_map = | 5283 Handle<Map> allocation_site_map = |
| 5284 masm->isolate()->factory()->allocation_site_map(); | 5284 masm->isolate()->factory()->allocation_site_map(); |
| 5285 __ Cmp(FieldOperand(rcx, 0), allocation_site_map); | 5285 __ Cmp(FieldOperand(rbx, 0), allocation_site_map); |
| 5286 __ Assert(equal, kExpectedAllocationSiteInCell); | 5286 __ Assert(equal, kExpectedAllocationSite); |
| 5287 } | 5287 } |
| 5288 | 5288 |
| 5289 // Save the resulting elements kind in type info. We can't just store r3 | 5289 // Save the resulting elements kind in type info. We can't just store r3 |
| 5290 // in the AllocationSite::transition_info field because elements kind is | 5290 // in the AllocationSite::transition_info field because elements kind is |
| 5291 // restricted to a portion of the field...upper bits need to be left alone. | 5291 // restricted to a portion of the field...upper bits need to be left alone. |
| 5292 STATIC_ASSERT(AllocationSite::ElementsKindBits::kShift == 0); | 5292 STATIC_ASSERT(AllocationSite::ElementsKindBits::kShift == 0); |
| 5293 __ SmiAddConstant(FieldOperand(rcx, AllocationSite::kTransitionInfoOffset), | 5293 __ SmiAddConstant(FieldOperand(rbx, AllocationSite::kTransitionInfoOffset), |
| 5294 Smi::FromInt(kFastElementsKindPackedToHoley)); | 5294 Smi::FromInt(kFastElementsKindPackedToHoley)); |
| 5295 | 5295 |
| 5296 __ bind(&normal_sequence); | 5296 __ bind(&normal_sequence); |
| 5297 int last_index = GetSequenceIndexFromFastElementsKind( | 5297 int last_index = GetSequenceIndexFromFastElementsKind( |
| 5298 TERMINAL_FAST_ELEMENTS_KIND); | 5298 TERMINAL_FAST_ELEMENTS_KIND); |
| 5299 for (int i = 0; i <= last_index; ++i) { | 5299 for (int i = 0; i <= last_index; ++i) { |
| 5300 Label next; | 5300 Label next; |
| 5301 ElementsKind kind = GetFastElementsKindFromSequenceIndex(i); | 5301 ElementsKind kind = GetFastElementsKindFromSequenceIndex(i); |
| 5302 __ cmpl(rdx, Immediate(kind)); | 5302 __ cmpl(rdx, Immediate(kind)); |
| 5303 __ j(not_equal, &next); | 5303 __ j(not_equal, &next); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5416 __ Cmp(FieldOperand(rbx, 0), cell_map); | 5416 __ Cmp(FieldOperand(rbx, 0), cell_map); |
| 5417 __ Assert(equal, kExpectedPropertyCellInRegisterRbx); | 5417 __ Assert(equal, kExpectedPropertyCellInRegisterRbx); |
| 5418 __ bind(&okay_here); | 5418 __ bind(&okay_here); |
| 5419 } | 5419 } |
| 5420 | 5420 |
| 5421 Label no_info; | 5421 Label no_info; |
| 5422 // If the type cell is undefined, or contains anything other than an | 5422 // If the type cell is undefined, or contains anything other than an |
| 5423 // AllocationSite, call an array constructor that doesn't use AllocationSites. | 5423 // AllocationSite, call an array constructor that doesn't use AllocationSites. |
| 5424 __ Cmp(rbx, undefined_sentinel); | 5424 __ Cmp(rbx, undefined_sentinel); |
| 5425 __ j(equal, &no_info); | 5425 __ j(equal, &no_info); |
| 5426 __ movp(rdx, FieldOperand(rbx, Cell::kValueOffset)); | 5426 __ movp(rbx, FieldOperand(rbx, Cell::kValueOffset)); |
| 5427 __ Cmp(FieldOperand(rdx, 0), | 5427 __ Cmp(FieldOperand(rbx, 0), |
| 5428 masm->isolate()->factory()->allocation_site_map()); | 5428 masm->isolate()->factory()->allocation_site_map()); |
| 5429 __ j(not_equal, &no_info); | 5429 __ j(not_equal, &no_info); |
| 5430 | 5430 |
| 5431 // Only look at the lower 16 bits of the transition info. | 5431 // Only look at the lower 16 bits of the transition info. |
| 5432 __ movp(rdx, FieldOperand(rdx, AllocationSite::kTransitionInfoOffset)); | 5432 __ movp(rdx, FieldOperand(rbx, AllocationSite::kTransitionInfoOffset)); |
| 5433 __ SmiToInteger32(rdx, rdx); | 5433 __ SmiToInteger32(rdx, rdx); |
| 5434 STATIC_ASSERT(AllocationSite::ElementsKindBits::kShift == 0); | 5434 STATIC_ASSERT(AllocationSite::ElementsKindBits::kShift == 0); |
| 5435 __ and_(rdx, Immediate(AllocationSite::ElementsKindBits::kMask)); | 5435 __ and_(rdx, Immediate(AllocationSite::ElementsKindBits::kMask)); |
| 5436 GenerateDispatchToArrayStub(masm, DONT_OVERRIDE); | 5436 GenerateDispatchToArrayStub(masm, DONT_OVERRIDE); |
| 5437 | 5437 |
| 5438 __ bind(&no_info); | 5438 __ bind(&no_info); |
| 5439 GenerateDispatchToArrayStub(masm, DISABLE_ALLOCATION_SITES); | 5439 GenerateDispatchToArrayStub(masm, DISABLE_ALLOCATION_SITES); |
| 5440 } | 5440 } |
| 5441 | 5441 |
| 5442 | 5442 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5528 __ bind(&fast_elements_case); | 5528 __ bind(&fast_elements_case); |
| 5529 GenerateCase(masm, FAST_ELEMENTS); | 5529 GenerateCase(masm, FAST_ELEMENTS); |
| 5530 } | 5530 } |
| 5531 | 5531 |
| 5532 | 5532 |
| 5533 #undef __ | 5533 #undef __ |
| 5534 | 5534 |
| 5535 } } // namespace v8::internal | 5535 } } // namespace v8::internal |
| 5536 | 5536 |
| 5537 #endif // V8_TARGET_ARCH_X64 | 5537 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |