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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 __ mov(edx, factory->undefined_value()); | 234 __ mov(edx, factory->undefined_value()); |
235 if (count_constructions) { | 235 if (count_constructions) { |
236 __ movzx_b(esi, | 236 __ movzx_b(esi, |
237 FieldOperand(eax, Map::kPreAllocatedPropertyFieldsOffset)); | 237 FieldOperand(eax, Map::kPreAllocatedPropertyFieldsOffset)); |
238 __ lea(esi, | 238 __ lea(esi, |
239 Operand(ebx, esi, times_pointer_size, JSObject::kHeaderSize)); | 239 Operand(ebx, esi, times_pointer_size, JSObject::kHeaderSize)); |
240 // esi: offset of first field after pre-allocated fields | 240 // esi: offset of first field after pre-allocated fields |
241 if (FLAG_debug_code) { | 241 if (FLAG_debug_code) { |
242 __ cmp(esi, edi); | 242 __ cmp(esi, edi); |
243 __ Assert(less_equal, | 243 __ Assert(less_equal, |
244 kUnexpectedNumberOfPreAllocatedPropertyFields); | 244 "Unexpected number of pre-allocated property fields."); |
245 } | 245 } |
246 __ InitializeFieldsWithFiller(ecx, esi, edx); | 246 __ InitializeFieldsWithFiller(ecx, esi, edx); |
247 __ mov(edx, factory->one_pointer_filler_map()); | 247 __ mov(edx, factory->one_pointer_filler_map()); |
248 } | 248 } |
249 __ InitializeFieldsWithFiller(ecx, edi, edx); | 249 __ InitializeFieldsWithFiller(ecx, edi, edx); |
250 | 250 |
251 // Add the object tag to make the JSObject real, so that we can continue | 251 // Add the object tag to make the JSObject real, so that we can continue |
252 // and jump into the continuation code at any time from now on. Any | 252 // and jump into the continuation code at any time from now on. Any |
253 // failures need to undo the allocation, so that the heap is in a | 253 // failures need to undo the allocation, so that the heap is in a |
254 // consistent state and verifiable. | 254 // consistent state and verifiable. |
(...skipping 10 matching lines...) Expand all Loading... |
265 // Calculate the total number of properties described by the map. | 265 // Calculate the total number of properties described by the map. |
266 __ movzx_b(edx, FieldOperand(eax, Map::kUnusedPropertyFieldsOffset)); | 266 __ movzx_b(edx, FieldOperand(eax, Map::kUnusedPropertyFieldsOffset)); |
267 __ movzx_b(ecx, | 267 __ movzx_b(ecx, |
268 FieldOperand(eax, Map::kPreAllocatedPropertyFieldsOffset)); | 268 FieldOperand(eax, Map::kPreAllocatedPropertyFieldsOffset)); |
269 __ add(edx, ecx); | 269 __ add(edx, ecx); |
270 // Calculate unused properties past the end of the in-object properties. | 270 // Calculate unused properties past the end of the in-object properties. |
271 __ movzx_b(ecx, FieldOperand(eax, Map::kInObjectPropertiesOffset)); | 271 __ movzx_b(ecx, FieldOperand(eax, Map::kInObjectPropertiesOffset)); |
272 __ sub(edx, ecx); | 272 __ sub(edx, ecx); |
273 // Done if no extra properties are to be allocated. | 273 // Done if no extra properties are to be allocated. |
274 __ j(zero, &allocated); | 274 __ j(zero, &allocated); |
275 __ Assert(positive, kPropertyAllocationCountFailed); | 275 __ Assert(positive, "Property allocation count failed."); |
276 | 276 |
277 // Scale the number of elements by pointer size and add the header for | 277 // Scale the number of elements by pointer size and add the header for |
278 // FixedArrays to the start of the next object calculation from above. | 278 // FixedArrays to the start of the next object calculation from above. |
279 // ebx: JSObject | 279 // ebx: JSObject |
280 // edi: start of next object (will be start of FixedArray) | 280 // edi: start of next object (will be start of FixedArray) |
281 // edx: number of elements in properties array | 281 // edx: number of elements in properties array |
282 __ Allocate(FixedArray::kHeaderSize, | 282 __ Allocate(FixedArray::kHeaderSize, |
283 times_pointer_size, | 283 times_pointer_size, |
284 edx, | 284 edx, |
285 REGISTER_VALUE_IS_INT32, | 285 REGISTER_VALUE_IS_INT32, |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 __ j(not_equal, ¬_no_registers, Label::kNear); | 647 __ j(not_equal, ¬_no_registers, Label::kNear); |
648 __ ret(1 * kPointerSize); // Remove state. | 648 __ ret(1 * kPointerSize); // Remove state. |
649 | 649 |
650 __ bind(¬_no_registers); | 650 __ bind(¬_no_registers); |
651 __ mov(eax, Operand(esp, 2 * kPointerSize)); | 651 __ mov(eax, Operand(esp, 2 * kPointerSize)); |
652 __ cmp(ecx, FullCodeGenerator::TOS_REG); | 652 __ cmp(ecx, FullCodeGenerator::TOS_REG); |
653 __ j(not_equal, ¬_tos_eax, Label::kNear); | 653 __ j(not_equal, ¬_tos_eax, Label::kNear); |
654 __ ret(2 * kPointerSize); // Remove state, eax. | 654 __ ret(2 * kPointerSize); // Remove state, eax. |
655 | 655 |
656 __ bind(¬_tos_eax); | 656 __ bind(¬_tos_eax); |
657 __ Abort(kNoCasesLeft); | 657 __ Abort("no cases left"); |
658 } | 658 } |
659 | 659 |
660 | 660 |
661 void Builtins::Generate_NotifyDeoptimized(MacroAssembler* masm) { | 661 void Builtins::Generate_NotifyDeoptimized(MacroAssembler* masm) { |
662 Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::EAGER); | 662 Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::EAGER); |
663 } | 663 } |
664 | 664 |
665 | 665 |
666 void Builtins::Generate_NotifySoftDeoptimized(MacroAssembler* masm) { | 666 void Builtins::Generate_NotifySoftDeoptimized(MacroAssembler* masm) { |
667 Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::SOFT); | 667 Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::SOFT); |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1026 Label generic_array_code; | 1026 Label generic_array_code; |
1027 | 1027 |
1028 // Get the InternalArray function. | 1028 // Get the InternalArray function. |
1029 __ LoadGlobalFunction(Context::INTERNAL_ARRAY_FUNCTION_INDEX, edi); | 1029 __ LoadGlobalFunction(Context::INTERNAL_ARRAY_FUNCTION_INDEX, edi); |
1030 | 1030 |
1031 if (FLAG_debug_code) { | 1031 if (FLAG_debug_code) { |
1032 // Initial map for the builtin InternalArray function should be a map. | 1032 // Initial map for the builtin InternalArray function should be a map. |
1033 __ mov(ebx, FieldOperand(edi, JSFunction::kPrototypeOrInitialMapOffset)); | 1033 __ mov(ebx, FieldOperand(edi, JSFunction::kPrototypeOrInitialMapOffset)); |
1034 // Will both indicate a NULL and a Smi. | 1034 // Will both indicate a NULL and a Smi. |
1035 __ test(ebx, Immediate(kSmiTagMask)); | 1035 __ test(ebx, Immediate(kSmiTagMask)); |
1036 __ Assert(not_zero, kUnexpectedInitialMapForInternalArrayFunction); | 1036 __ Assert(not_zero, "Unexpected initial map for InternalArray function"); |
1037 __ CmpObjectType(ebx, MAP_TYPE, ecx); | 1037 __ CmpObjectType(ebx, MAP_TYPE, ecx); |
1038 __ Assert(equal, kUnexpectedInitialMapForInternalArrayFunction); | 1038 __ Assert(equal, "Unexpected initial map for InternalArray function"); |
1039 } | 1039 } |
1040 | 1040 |
1041 // Run the native code for the InternalArray function called as a normal | 1041 // Run the native code for the InternalArray function called as a normal |
1042 // function. | 1042 // function. |
1043 // tail call a stub | 1043 // tail call a stub |
1044 InternalArrayConstructorStub stub(masm->isolate()); | 1044 InternalArrayConstructorStub stub(masm->isolate()); |
1045 __ TailCallStub(&stub); | 1045 __ TailCallStub(&stub); |
1046 } | 1046 } |
1047 | 1047 |
1048 | 1048 |
1049 void Builtins::Generate_ArrayCode(MacroAssembler* masm) { | 1049 void Builtins::Generate_ArrayCode(MacroAssembler* masm) { |
1050 // ----------- S t a t e ------------- | 1050 // ----------- S t a t e ------------- |
1051 // -- eax : argc | 1051 // -- eax : argc |
1052 // -- esp[0] : return address | 1052 // -- esp[0] : return address |
1053 // -- esp[4] : last argument | 1053 // -- esp[4] : last argument |
1054 // ----------------------------------- | 1054 // ----------------------------------- |
1055 Label generic_array_code; | 1055 Label generic_array_code; |
1056 | 1056 |
1057 // Get the Array function. | 1057 // Get the Array function. |
1058 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, edi); | 1058 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, edi); |
1059 | 1059 |
1060 if (FLAG_debug_code) { | 1060 if (FLAG_debug_code) { |
1061 // Initial map for the builtin Array function should be a map. | 1061 // Initial map for the builtin Array function should be a map. |
1062 __ mov(ebx, FieldOperand(edi, JSFunction::kPrototypeOrInitialMapOffset)); | 1062 __ mov(ebx, FieldOperand(edi, JSFunction::kPrototypeOrInitialMapOffset)); |
1063 // Will both indicate a NULL and a Smi. | 1063 // Will both indicate a NULL and a Smi. |
1064 __ test(ebx, Immediate(kSmiTagMask)); | 1064 __ test(ebx, Immediate(kSmiTagMask)); |
1065 __ Assert(not_zero, kUnexpectedInitialMapForArrayFunction); | 1065 __ Assert(not_zero, "Unexpected initial map for Array function"); |
1066 __ CmpObjectType(ebx, MAP_TYPE, ecx); | 1066 __ CmpObjectType(ebx, MAP_TYPE, ecx); |
1067 __ Assert(equal, kUnexpectedInitialMapForArrayFunction); | 1067 __ Assert(equal, "Unexpected initial map for Array function"); |
1068 } | 1068 } |
1069 | 1069 |
1070 // Run the native code for the Array function called as a normal function. | 1070 // Run the native code for the Array function called as a normal function. |
1071 // tail call a stub | 1071 // tail call a stub |
1072 Handle<Object> undefined_sentinel( | 1072 Handle<Object> undefined_sentinel( |
1073 masm->isolate()->heap()->undefined_value(), | 1073 masm->isolate()->heap()->undefined_value(), |
1074 masm->isolate()); | 1074 masm->isolate()); |
1075 __ mov(ebx, Immediate(undefined_sentinel)); | 1075 __ mov(ebx, Immediate(undefined_sentinel)); |
1076 ArrayConstructorStub stub(masm->isolate()); | 1076 ArrayConstructorStub stub(masm->isolate()); |
1077 __ TailCallStub(&stub); | 1077 __ TailCallStub(&stub); |
1078 } | 1078 } |
1079 | 1079 |
1080 | 1080 |
1081 void Builtins::Generate_StringConstructCode(MacroAssembler* masm) { | 1081 void Builtins::Generate_StringConstructCode(MacroAssembler* masm) { |
1082 // ----------- S t a t e ------------- | 1082 // ----------- S t a t e ------------- |
1083 // -- eax : number of arguments | 1083 // -- eax : number of arguments |
1084 // -- edi : constructor function | 1084 // -- edi : constructor function |
1085 // -- esp[0] : return address | 1085 // -- esp[0] : return address |
1086 // -- esp[(argc - n) * 4] : arg[n] (zero-based) | 1086 // -- esp[(argc - n) * 4] : arg[n] (zero-based) |
1087 // -- esp[(argc + 1) * 4] : receiver | 1087 // -- esp[(argc + 1) * 4] : receiver |
1088 // ----------------------------------- | 1088 // ----------------------------------- |
1089 Counters* counters = masm->isolate()->counters(); | 1089 Counters* counters = masm->isolate()->counters(); |
1090 __ IncrementCounter(counters->string_ctor_calls(), 1); | 1090 __ IncrementCounter(counters->string_ctor_calls(), 1); |
1091 | 1091 |
1092 if (FLAG_debug_code) { | 1092 if (FLAG_debug_code) { |
1093 __ LoadGlobalFunction(Context::STRING_FUNCTION_INDEX, ecx); | 1093 __ LoadGlobalFunction(Context::STRING_FUNCTION_INDEX, ecx); |
1094 __ cmp(edi, ecx); | 1094 __ cmp(edi, ecx); |
1095 __ Assert(equal, kUnexpectedStringFunction); | 1095 __ Assert(equal, "Unexpected String function"); |
1096 } | 1096 } |
1097 | 1097 |
1098 // Load the first argument into eax and get rid of the rest | 1098 // Load the first argument into eax and get rid of the rest |
1099 // (including the receiver). | 1099 // (including the receiver). |
1100 Label no_arguments; | 1100 Label no_arguments; |
1101 __ test(eax, eax); | 1101 __ test(eax, eax); |
1102 __ j(zero, &no_arguments); | 1102 __ j(zero, &no_arguments); |
1103 __ mov(ebx, Operand(esp, eax, times_pointer_size, 0)); | 1103 __ mov(ebx, Operand(esp, eax, times_pointer_size, 0)); |
1104 __ pop(ecx); | 1104 __ pop(ecx); |
1105 __ lea(esp, Operand(esp, eax, times_pointer_size, kPointerSize)); | 1105 __ lea(esp, Operand(esp, eax, times_pointer_size, kPointerSize)); |
(...skipping 24 matching lines...) Expand all Loading... |
1130 ecx, // New allocation top (we ignore it). | 1130 ecx, // New allocation top (we ignore it). |
1131 no_reg, | 1131 no_reg, |
1132 &gc_required, | 1132 &gc_required, |
1133 TAG_OBJECT); | 1133 TAG_OBJECT); |
1134 | 1134 |
1135 // Set the map. | 1135 // Set the map. |
1136 __ LoadGlobalFunctionInitialMap(edi, ecx); | 1136 __ LoadGlobalFunctionInitialMap(edi, ecx); |
1137 if (FLAG_debug_code) { | 1137 if (FLAG_debug_code) { |
1138 __ cmpb(FieldOperand(ecx, Map::kInstanceSizeOffset), | 1138 __ cmpb(FieldOperand(ecx, Map::kInstanceSizeOffset), |
1139 JSValue::kSize >> kPointerSizeLog2); | 1139 JSValue::kSize >> kPointerSizeLog2); |
1140 __ Assert(equal, kUnexpectedStringWrapperInstanceSize); | 1140 __ Assert(equal, "Unexpected string wrapper instance size"); |
1141 __ cmpb(FieldOperand(ecx, Map::kUnusedPropertyFieldsOffset), 0); | 1141 __ cmpb(FieldOperand(ecx, Map::kUnusedPropertyFieldsOffset), 0); |
1142 __ Assert(equal, kUnexpectedUnusedPropertiesOfStringWrapper); | 1142 __ Assert(equal, "Unexpected unused properties of string wrapper"); |
1143 } | 1143 } |
1144 __ mov(FieldOperand(eax, HeapObject::kMapOffset), ecx); | 1144 __ mov(FieldOperand(eax, HeapObject::kMapOffset), ecx); |
1145 | 1145 |
1146 // Set properties and elements. | 1146 // Set properties and elements. |
1147 Factory* factory = masm->isolate()->factory(); | 1147 Factory* factory = masm->isolate()->factory(); |
1148 __ Set(ecx, Immediate(factory->empty_fixed_array())); | 1148 __ Set(ecx, Immediate(factory->empty_fixed_array())); |
1149 __ mov(FieldOperand(eax, JSObject::kPropertiesOffset), ecx); | 1149 __ mov(FieldOperand(eax, JSObject::kPropertiesOffset), ecx); |
1150 __ mov(FieldOperand(eax, JSObject::kElementsOffset), ecx); | 1150 __ mov(FieldOperand(eax, JSObject::kElementsOffset), ecx); |
1151 | 1151 |
1152 // Set the value. | 1152 // Set the value. |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1354 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); | 1354 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); |
1355 generator.Generate(); | 1355 generator.Generate(); |
1356 } | 1356 } |
1357 | 1357 |
1358 | 1358 |
1359 #undef __ | 1359 #undef __ |
1360 } | 1360 } |
1361 } // namespace v8::internal | 1361 } // namespace v8::internal |
1362 | 1362 |
1363 #endif // V8_TARGET_ARCH_IA32 | 1363 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |