| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #if V8_TARGET_ARCH_X87 | 7 #if V8_TARGET_ARCH_X87 |
| 8 | 8 |
| 9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
| 10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
| 11 #include "src/codegen.h" | 11 #include "src/codegen.h" |
| 12 #include "src/isolate.h" | 12 #include "src/isolate.h" |
| 13 #include "src/jsregexp.h" | 13 #include "src/jsregexp.h" |
| 14 #include "src/regexp-macro-assembler.h" | 14 #include "src/regexp-macro-assembler.h" |
| 15 #include "src/runtime.h" | 15 #include "src/runtime.h" |
| 16 #include "src/stub-cache.h" | 16 #include "src/stub-cache.h" |
| 17 | 17 |
| 18 namespace v8 { | 18 namespace v8 { |
| 19 namespace internal { | 19 namespace internal { |
| 20 | 20 |
| 21 | 21 |
| 22 void FastNewClosureStub::InitializeInterfaceDescriptor( | 22 void FastNewClosureStub::InitializeInterfaceDescriptor( |
| 23 CodeStubInterfaceDescriptor* descriptor) { | 23 CodeStubInterfaceDescriptor* descriptor) { |
| 24 Register registers[] = { esi, ebx }; | 24 Register registers[] = { esi, ebx }; |
| 25 descriptor->Initialize( | 25 descriptor->Initialize( |
| 26 ARRAY_SIZE(registers), registers, | 26 MajorKey(), ARRAY_SIZE(registers), registers, |
| 27 Runtime::FunctionForId(Runtime::kNewClosureFromStubFailure)->entry); | 27 Runtime::FunctionForId(Runtime::kNewClosureFromStubFailure)->entry); |
| 28 } | 28 } |
| 29 | 29 |
| 30 | 30 |
| 31 void FastNewContextStub::InitializeInterfaceDescriptor( | 31 void FastNewContextStub::InitializeInterfaceDescriptor( |
| 32 CodeStubInterfaceDescriptor* descriptor) { | 32 CodeStubInterfaceDescriptor* descriptor) { |
| 33 Register registers[] = { esi, edi }; | 33 Register registers[] = { esi, edi }; |
| 34 descriptor->Initialize(ARRAY_SIZE(registers), registers); | 34 descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers); |
| 35 } | 35 } |
| 36 | 36 |
| 37 | 37 |
| 38 void ToNumberStub::InitializeInterfaceDescriptor( | 38 void ToNumberStub::InitializeInterfaceDescriptor( |
| 39 CodeStubInterfaceDescriptor* descriptor) { | 39 CodeStubInterfaceDescriptor* descriptor) { |
| 40 // ToNumberStub invokes a function, and therefore needs a context. | 40 // ToNumberStub invokes a function, and therefore needs a context. |
| 41 Register registers[] = { esi, eax }; | 41 Register registers[] = { esi, eax }; |
| 42 descriptor->Initialize(ARRAY_SIZE(registers), registers); | 42 descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers); |
| 43 } | 43 } |
| 44 | 44 |
| 45 | 45 |
| 46 void NumberToStringStub::InitializeInterfaceDescriptor( | 46 void NumberToStringStub::InitializeInterfaceDescriptor( |
| 47 CodeStubInterfaceDescriptor* descriptor) { | 47 CodeStubInterfaceDescriptor* descriptor) { |
| 48 Register registers[] = { esi, eax }; | 48 Register registers[] = { esi, eax }; |
| 49 descriptor->Initialize( | 49 descriptor->Initialize( |
| 50 ARRAY_SIZE(registers), registers, | 50 MajorKey(), ARRAY_SIZE(registers), registers, |
| 51 Runtime::FunctionForId(Runtime::kNumberToStringRT)->entry); | 51 Runtime::FunctionForId(Runtime::kNumberToStringRT)->entry); |
| 52 } | 52 } |
| 53 | 53 |
| 54 | 54 |
| 55 void FastCloneShallowArrayStub::InitializeInterfaceDescriptor( | 55 void FastCloneShallowArrayStub::InitializeInterfaceDescriptor( |
| 56 CodeStubInterfaceDescriptor* descriptor) { | 56 CodeStubInterfaceDescriptor* descriptor) { |
| 57 Register registers[] = { esi, eax, ebx, ecx }; | 57 Register registers[] = { esi, eax, ebx, ecx }; |
| 58 Representation representations[] = { | 58 Representation representations[] = { |
| 59 Representation::Tagged(), | 59 Representation::Tagged(), |
| 60 Representation::Tagged(), | 60 Representation::Tagged(), |
| 61 Representation::Smi(), | 61 Representation::Smi(), |
| 62 Representation::Tagged() }; | 62 Representation::Tagged() }; |
| 63 | 63 |
| 64 descriptor->Initialize( | 64 descriptor->Initialize( |
| 65 ARRAY_SIZE(registers), registers, | 65 MajorKey(), ARRAY_SIZE(registers), registers, |
| 66 Runtime::FunctionForId( | 66 Runtime::FunctionForId(Runtime::kCreateArrayLiteralStubBailout)->entry, |
| 67 Runtime::kCreateArrayLiteralStubBailout)->entry, | |
| 68 representations); | 67 representations); |
| 69 } | 68 } |
| 70 | 69 |
| 71 | 70 |
| 72 void FastCloneShallowObjectStub::InitializeInterfaceDescriptor( | 71 void FastCloneShallowObjectStub::InitializeInterfaceDescriptor( |
| 73 CodeStubInterfaceDescriptor* descriptor) { | 72 CodeStubInterfaceDescriptor* descriptor) { |
| 74 Register registers[] = { esi, eax, ebx, ecx, edx }; | 73 Register registers[] = { esi, eax, ebx, ecx, edx }; |
| 75 descriptor->Initialize( | 74 descriptor->Initialize( |
| 76 ARRAY_SIZE(registers), registers, | 75 MajorKey(), ARRAY_SIZE(registers), registers, |
| 77 Runtime::FunctionForId(Runtime::kCreateObjectLiteral)->entry); | 76 Runtime::FunctionForId(Runtime::kCreateObjectLiteral)->entry); |
| 78 } | 77 } |
| 79 | 78 |
| 80 | 79 |
| 81 void CreateAllocationSiteStub::InitializeInterfaceDescriptor( | 80 void CreateAllocationSiteStub::InitializeInterfaceDescriptor( |
| 82 CodeStubInterfaceDescriptor* descriptor) { | 81 CodeStubInterfaceDescriptor* descriptor) { |
| 83 Register registers[] = { esi, ebx, edx }; | 82 Register registers[] = { esi, ebx, edx }; |
| 84 descriptor->Initialize(ARRAY_SIZE(registers), registers); | 83 descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers); |
| 85 } | 84 } |
| 86 | 85 |
| 87 | 86 |
| 88 void RegExpConstructResultStub::InitializeInterfaceDescriptor( | 87 void RegExpConstructResultStub::InitializeInterfaceDescriptor( |
| 89 CodeStubInterfaceDescriptor* descriptor) { | 88 CodeStubInterfaceDescriptor* descriptor) { |
| 90 Register registers[] = { esi, ecx, ebx, eax }; | 89 Register registers[] = { esi, ecx, ebx, eax }; |
| 91 descriptor->Initialize( | 90 descriptor->Initialize( |
| 92 ARRAY_SIZE(registers), registers, | 91 MajorKey(), ARRAY_SIZE(registers), registers, |
| 93 Runtime::FunctionForId(Runtime::kRegExpConstructResult)->entry); | 92 Runtime::FunctionForId(Runtime::kRegExpConstructResult)->entry); |
| 94 } | 93 } |
| 95 | 94 |
| 96 | 95 |
| 97 void TransitionElementsKindStub::InitializeInterfaceDescriptor( | 96 void TransitionElementsKindStub::InitializeInterfaceDescriptor( |
| 98 CodeStubInterfaceDescriptor* descriptor) { | 97 CodeStubInterfaceDescriptor* descriptor) { |
| 99 Register registers[] = { esi, eax, ebx }; | 98 Register registers[] = { esi, eax, ebx }; |
| 100 descriptor->Initialize( | 99 descriptor->Initialize( |
| 101 ARRAY_SIZE(registers), registers, | 100 MajorKey(), ARRAY_SIZE(registers), registers, |
| 102 Runtime::FunctionForId(Runtime::kTransitionElementsKind)->entry); | 101 Runtime::FunctionForId(Runtime::kTransitionElementsKind)->entry); |
| 103 } | 102 } |
| 104 | 103 |
| 105 | 104 |
| 106 const Register InterfaceDescriptor::ContextRegister() { return esi; } | 105 const Register InterfaceDescriptor::ContextRegister() { return esi; } |
| 107 | 106 |
| 108 | 107 |
| 109 static void InitializeArrayConstructorDescriptor( | 108 static void InitializeArrayConstructorDescriptor( |
| 110 Isolate* isolate, | 109 Isolate* isolate, CodeStub::Major major, |
| 111 CodeStubInterfaceDescriptor* descriptor, | 110 CodeStubInterfaceDescriptor* descriptor, |
| 112 int constant_stack_parameter_count) { | 111 int constant_stack_parameter_count) { |
| 113 // register state | 112 // register state |
| 114 // eax -- number of arguments | 113 // eax -- number of arguments |
| 115 // edi -- function | 114 // edi -- function |
| 116 // ebx -- allocation site with elements kind | 115 // ebx -- allocation site with elements kind |
| 117 Address deopt_handler = Runtime::FunctionForId( | 116 Address deopt_handler = Runtime::FunctionForId( |
| 118 Runtime::kArrayConstructor)->entry; | 117 Runtime::kArrayConstructor)->entry; |
| 119 | 118 |
| 120 if (constant_stack_parameter_count == 0) { | 119 if (constant_stack_parameter_count == 0) { |
| 121 Register registers[] = { esi, edi, ebx }; | 120 Register registers[] = { esi, edi, ebx }; |
| 122 descriptor->Initialize(ARRAY_SIZE(registers), registers, | 121 descriptor->Initialize(major, ARRAY_SIZE(registers), registers, |
| 123 deopt_handler, | 122 deopt_handler, NULL, constant_stack_parameter_count, |
| 124 NULL, | |
| 125 constant_stack_parameter_count, | |
| 126 JS_FUNCTION_STUB_MODE); | 123 JS_FUNCTION_STUB_MODE); |
| 127 } else { | 124 } else { |
| 128 // stack param count needs (constructor pointer, and single argument) | 125 // stack param count needs (constructor pointer, and single argument) |
| 129 Register registers[] = { esi, edi, ebx, eax }; | 126 Register registers[] = { esi, edi, ebx, eax }; |
| 130 Representation representations[] = { | 127 Representation representations[] = { |
| 131 Representation::Tagged(), | 128 Representation::Tagged(), |
| 132 Representation::Tagged(), | 129 Representation::Tagged(), |
| 133 Representation::Tagged(), | 130 Representation::Tagged(), |
| 134 Representation::Integer32() }; | 131 Representation::Integer32() }; |
| 135 descriptor->Initialize(ARRAY_SIZE(registers), registers, | 132 descriptor->Initialize(major, ARRAY_SIZE(registers), registers, eax, |
| 136 eax, | 133 deopt_handler, representations, |
| 137 deopt_handler, | |
| 138 representations, | |
| 139 constant_stack_parameter_count, | 134 constant_stack_parameter_count, |
| 140 JS_FUNCTION_STUB_MODE, | 135 JS_FUNCTION_STUB_MODE, PASS_ARGUMENTS); |
| 141 PASS_ARGUMENTS); | |
| 142 } | 136 } |
| 143 } | 137 } |
| 144 | 138 |
| 145 | 139 |
| 146 static void InitializeInternalArrayConstructorDescriptor( | 140 static void InitializeInternalArrayConstructorDescriptor( |
| 147 CodeStubInterfaceDescriptor* descriptor, | 141 CodeStub::Major major, CodeStubInterfaceDescriptor* descriptor, |
| 148 int constant_stack_parameter_count) { | 142 int constant_stack_parameter_count) { |
| 149 // register state | 143 // register state |
| 150 // eax -- number of arguments | 144 // eax -- number of arguments |
| 151 // edi -- constructor function | 145 // edi -- constructor function |
| 152 Address deopt_handler = Runtime::FunctionForId( | 146 Address deopt_handler = Runtime::FunctionForId( |
| 153 Runtime::kInternalArrayConstructor)->entry; | 147 Runtime::kInternalArrayConstructor)->entry; |
| 154 | 148 |
| 155 if (constant_stack_parameter_count == 0) { | 149 if (constant_stack_parameter_count == 0) { |
| 156 Register registers[] = { esi, edi }; | 150 Register registers[] = { esi, edi }; |
| 157 descriptor->Initialize(ARRAY_SIZE(registers), registers, | 151 descriptor->Initialize(major, ARRAY_SIZE(registers), registers, |
| 158 deopt_handler, | 152 deopt_handler, NULL, constant_stack_parameter_count, |
| 159 NULL, | |
| 160 constant_stack_parameter_count, | |
| 161 JS_FUNCTION_STUB_MODE); | 153 JS_FUNCTION_STUB_MODE); |
| 162 } else { | 154 } else { |
| 163 // stack param count needs (constructor pointer, and single argument) | 155 // stack param count needs (constructor pointer, and single argument) |
| 164 Register registers[] = { esi, edi, eax }; | 156 Register registers[] = { esi, edi, eax }; |
| 165 Representation representations[] = { | 157 Representation representations[] = { |
| 166 Representation::Tagged(), | 158 Representation::Tagged(), |
| 167 Representation::Tagged(), | 159 Representation::Tagged(), |
| 168 Representation::Integer32() }; | 160 Representation::Integer32() }; |
| 169 descriptor->Initialize(ARRAY_SIZE(registers), registers, | 161 descriptor->Initialize(major, ARRAY_SIZE(registers), registers, eax, |
| 170 eax, | 162 deopt_handler, representations, |
| 171 deopt_handler, | |
| 172 representations, | |
| 173 constant_stack_parameter_count, | 163 constant_stack_parameter_count, |
| 174 JS_FUNCTION_STUB_MODE, | 164 JS_FUNCTION_STUB_MODE, PASS_ARGUMENTS); |
| 175 PASS_ARGUMENTS); | |
| 176 } | 165 } |
| 177 } | 166 } |
| 178 | 167 |
| 179 | 168 |
| 180 void ArrayNoArgumentConstructorStub::InitializeInterfaceDescriptor( | 169 void ArrayNoArgumentConstructorStub::InitializeInterfaceDescriptor( |
| 181 CodeStubInterfaceDescriptor* descriptor) { | 170 CodeStubInterfaceDescriptor* descriptor) { |
| 182 InitializeArrayConstructorDescriptor(isolate(), descriptor, 0); | 171 InitializeArrayConstructorDescriptor(isolate(), MajorKey(), descriptor, 0); |
| 183 } | 172 } |
| 184 | 173 |
| 185 | 174 |
| 186 void ArraySingleArgumentConstructorStub::InitializeInterfaceDescriptor( | 175 void ArraySingleArgumentConstructorStub::InitializeInterfaceDescriptor( |
| 187 CodeStubInterfaceDescriptor* descriptor) { | 176 CodeStubInterfaceDescriptor* descriptor) { |
| 188 InitializeArrayConstructorDescriptor(isolate(), descriptor, 1); | 177 InitializeArrayConstructorDescriptor(isolate(), MajorKey(), descriptor, 1); |
| 189 } | 178 } |
| 190 | 179 |
| 191 | 180 |
| 192 void ArrayNArgumentsConstructorStub::InitializeInterfaceDescriptor( | 181 void ArrayNArgumentsConstructorStub::InitializeInterfaceDescriptor( |
| 193 CodeStubInterfaceDescriptor* descriptor) { | 182 CodeStubInterfaceDescriptor* descriptor) { |
| 194 InitializeArrayConstructorDescriptor(isolate(), descriptor, -1); | 183 InitializeArrayConstructorDescriptor(isolate(), MajorKey(), descriptor, -1); |
| 195 } | 184 } |
| 196 | 185 |
| 197 | 186 |
| 198 void InternalArrayNoArgumentConstructorStub::InitializeInterfaceDescriptor( | 187 void InternalArrayNoArgumentConstructorStub::InitializeInterfaceDescriptor( |
| 199 CodeStubInterfaceDescriptor* descriptor) { | 188 CodeStubInterfaceDescriptor* descriptor) { |
| 200 InitializeInternalArrayConstructorDescriptor(descriptor, 0); | 189 InitializeInternalArrayConstructorDescriptor(MajorKey(), descriptor, 0); |
| 201 } | 190 } |
| 202 | 191 |
| 203 | 192 |
| 204 void InternalArraySingleArgumentConstructorStub::InitializeInterfaceDescriptor( | 193 void InternalArraySingleArgumentConstructorStub::InitializeInterfaceDescriptor( |
| 205 CodeStubInterfaceDescriptor* descriptor) { | 194 CodeStubInterfaceDescriptor* descriptor) { |
| 206 InitializeInternalArrayConstructorDescriptor(descriptor, 1); | 195 InitializeInternalArrayConstructorDescriptor(MajorKey(), descriptor, 1); |
| 207 } | 196 } |
| 208 | 197 |
| 209 | 198 |
| 210 void InternalArrayNArgumentsConstructorStub::InitializeInterfaceDescriptor( | 199 void InternalArrayNArgumentsConstructorStub::InitializeInterfaceDescriptor( |
| 211 CodeStubInterfaceDescriptor* descriptor) { | 200 CodeStubInterfaceDescriptor* descriptor) { |
| 212 InitializeInternalArrayConstructorDescriptor(descriptor, -1); | 201 InitializeInternalArrayConstructorDescriptor(MajorKey(), descriptor, -1); |
| 213 } | 202 } |
| 214 | 203 |
| 215 | 204 |
| 216 void CompareNilICStub::InitializeInterfaceDescriptor( | 205 void CompareNilICStub::InitializeInterfaceDescriptor( |
| 217 CodeStubInterfaceDescriptor* descriptor) { | 206 CodeStubInterfaceDescriptor* descriptor) { |
| 218 Register registers[] = { esi, eax }; | 207 Register registers[] = { esi, eax }; |
| 219 descriptor->Initialize(ARRAY_SIZE(registers), registers, | 208 descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers, |
| 220 FUNCTION_ADDR(CompareNilIC_Miss)); | 209 FUNCTION_ADDR(CompareNilIC_Miss)); |
| 221 descriptor->SetMissHandler( | 210 descriptor->SetMissHandler( |
| 222 ExternalReference(IC_Utility(IC::kCompareNilIC_Miss), isolate())); | 211 ExternalReference(IC_Utility(IC::kCompareNilIC_Miss), isolate())); |
| 223 } | 212 } |
| 224 | 213 |
| 225 void ToBooleanStub::InitializeInterfaceDescriptor( | 214 void ToBooleanStub::InitializeInterfaceDescriptor( |
| 226 CodeStubInterfaceDescriptor* descriptor) { | 215 CodeStubInterfaceDescriptor* descriptor) { |
| 227 Register registers[] = { esi, eax }; | 216 Register registers[] = { esi, eax }; |
| 228 descriptor->Initialize(ARRAY_SIZE(registers), registers, | 217 descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers, |
| 229 FUNCTION_ADDR(ToBooleanIC_Miss)); | 218 FUNCTION_ADDR(ToBooleanIC_Miss)); |
| 230 descriptor->SetMissHandler( | 219 descriptor->SetMissHandler( |
| 231 ExternalReference(IC_Utility(IC::kToBooleanIC_Miss), isolate())); | 220 ExternalReference(IC_Utility(IC::kToBooleanIC_Miss), isolate())); |
| 232 } | 221 } |
| 233 | 222 |
| 234 | 223 |
| 235 void BinaryOpICStub::InitializeInterfaceDescriptor( | 224 void BinaryOpICStub::InitializeInterfaceDescriptor( |
| 236 CodeStubInterfaceDescriptor* descriptor) { | 225 CodeStubInterfaceDescriptor* descriptor) { |
| 237 Register registers[] = { esi, edx, eax }; | 226 Register registers[] = { esi, edx, eax }; |
| 238 descriptor->Initialize(ARRAY_SIZE(registers), registers, | 227 descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers, |
| 239 FUNCTION_ADDR(BinaryOpIC_Miss)); | 228 FUNCTION_ADDR(BinaryOpIC_Miss)); |
| 240 descriptor->SetMissHandler( | 229 descriptor->SetMissHandler( |
| 241 ExternalReference(IC_Utility(IC::kBinaryOpIC_Miss), isolate())); | 230 ExternalReference(IC_Utility(IC::kBinaryOpIC_Miss), isolate())); |
| 242 } | 231 } |
| 243 | 232 |
| 244 | 233 |
| 245 void BinaryOpWithAllocationSiteStub::InitializeInterfaceDescriptor( | 234 void BinaryOpWithAllocationSiteStub::InitializeInterfaceDescriptor( |
| 246 CodeStubInterfaceDescriptor* descriptor) { | 235 CodeStubInterfaceDescriptor* descriptor) { |
| 247 Register registers[] = { esi, ecx, edx, eax }; | 236 Register registers[] = { esi, ecx, edx, eax }; |
| 248 descriptor->Initialize(ARRAY_SIZE(registers), registers, | 237 descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers, |
| 249 FUNCTION_ADDR(BinaryOpIC_MissWithAllocationSite)); | 238 FUNCTION_ADDR(BinaryOpIC_MissWithAllocationSite)); |
| 250 } | 239 } |
| 251 | 240 |
| 252 | 241 |
| 253 void StringAddStub::InitializeInterfaceDescriptor( | 242 void StringAddStub::InitializeInterfaceDescriptor( |
| 254 CodeStubInterfaceDescriptor* descriptor) { | 243 CodeStubInterfaceDescriptor* descriptor) { |
| 255 Register registers[] = { esi, edx, eax }; | 244 Register registers[] = { esi, edx, eax }; |
| 256 descriptor->Initialize( | 245 descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers, |
| 257 ARRAY_SIZE(registers), registers, | 246 Runtime::FunctionForId(Runtime::kStringAdd)->entry); |
| 258 Runtime::FunctionForId(Runtime::kStringAdd)->entry); | |
| 259 } | 247 } |
| 260 | 248 |
| 261 | 249 |
| 262 void CallDescriptors::InitializeForIsolate(Isolate* isolate) { | 250 void CallDescriptors::InitializeForIsolate(Isolate* isolate) { |
| 263 { | 251 { |
| 264 CallInterfaceDescriptor* descriptor = | 252 CallInterfaceDescriptor* descriptor = |
| 265 isolate->call_descriptor(Isolate::ArgumentAdaptorCall); | 253 isolate->call_descriptor(Isolate::ArgumentAdaptorCall); |
| 266 Register registers[] = { esi, // context | 254 Register registers[] = { esi, // context |
| 267 edi, // JSFunction | 255 edi, // JSFunction |
| 268 eax, // actual number of arguments | 256 eax, // actual number of arguments |
| (...skipping 4349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4618 Operand(ebp, 7 * kPointerSize), | 4606 Operand(ebp, 7 * kPointerSize), |
| 4619 NULL); | 4607 NULL); |
| 4620 } | 4608 } |
| 4621 | 4609 |
| 4622 | 4610 |
| 4623 #undef __ | 4611 #undef __ |
| 4624 | 4612 |
| 4625 } } // namespace v8::internal | 4613 } } // namespace v8::internal |
| 4626 | 4614 |
| 4627 #endif // V8_TARGET_ARCH_X87 | 4615 #endif // V8_TARGET_ARCH_X87 |
| OLD | NEW |