| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/code-factory.h" | 5 #include "src/code-factory.h" |
| 6 | 6 |
| 7 #include "src/bootstrapper.h" | 7 #include "src/bootstrapper.h" |
| 8 #include "src/ic/ic.h" | 8 #include "src/ic/ic.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 return make_callable(stub); | 147 return make_callable(stub); |
| 148 } | 148 } |
| 149 | 149 |
| 150 // static | 150 // static |
| 151 Callable CodeFactory::BinaryOpIC(Isolate* isolate, Token::Value op) { | 151 Callable CodeFactory::BinaryOpIC(Isolate* isolate, Token::Value op) { |
| 152 BinaryOpICStub stub(isolate, op); | 152 BinaryOpICStub stub(isolate, op); |
| 153 return make_callable(stub); | 153 return make_callable(stub); |
| 154 } | 154 } |
| 155 | 155 |
| 156 // static | 156 // static |
| 157 Callable CodeFactory::InstanceOf(Isolate* isolate) { | |
| 158 InstanceOfStub stub(isolate); | |
| 159 return make_callable(stub); | |
| 160 } | |
| 161 | |
| 162 // static | |
| 163 Callable CodeFactory::GetProperty(Isolate* isolate) { | 157 Callable CodeFactory::GetProperty(Isolate* isolate) { |
| 164 GetPropertyStub stub(isolate); | 158 GetPropertyStub stub(isolate); |
| 165 return make_callable(stub); | 159 return make_callable(stub); |
| 166 } | 160 } |
| 167 | 161 |
| 168 // static | 162 // static |
| 169 Callable CodeFactory::ToBoolean(Isolate* isolate) { | 163 Callable CodeFactory::ToBoolean(Isolate* isolate) { |
| 170 return Callable(isolate->builtins()->ToBoolean(), | 164 return Callable(isolate->builtins()->ToBoolean(), |
| 171 TypeConversionDescriptor(isolate)); | 165 TypeConversionDescriptor(isolate)); |
| 172 } | 166 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 183 TypeConversionDescriptor(isolate)); | 177 TypeConversionDescriptor(isolate)); |
| 184 } | 178 } |
| 185 | 179 |
| 186 // static | 180 // static |
| 187 Callable CodeFactory::StringToNumber(Isolate* isolate) { | 181 Callable CodeFactory::StringToNumber(Isolate* isolate) { |
| 188 return Callable(isolate->builtins()->StringToNumber(), | 182 return Callable(isolate->builtins()->StringToNumber(), |
| 189 TypeConversionDescriptor(isolate)); | 183 TypeConversionDescriptor(isolate)); |
| 190 } | 184 } |
| 191 | 185 |
| 192 // static | 186 // static |
| 193 Callable CodeFactory::ToString(Isolate* isolate) { | |
| 194 return Callable(isolate->builtins()->ToString(), | |
| 195 TypeConversionDescriptor(isolate)); | |
| 196 } | |
| 197 | |
| 198 // static | |
| 199 Callable CodeFactory::ToName(Isolate* isolate) { | 187 Callable CodeFactory::ToName(Isolate* isolate) { |
| 200 return Callable(isolate->builtins()->ToName(), | 188 return Callable(isolate->builtins()->ToName(), |
| 201 TypeConversionDescriptor(isolate)); | 189 TypeConversionDescriptor(isolate)); |
| 202 } | 190 } |
| 203 | 191 |
| 204 // static | 192 // static |
| 205 Callable CodeFactory::ToInteger(Isolate* isolate) { | |
| 206 ToIntegerStub stub(isolate); | |
| 207 return make_callable(stub); | |
| 208 } | |
| 209 | |
| 210 // static | |
| 211 Callable CodeFactory::ToLength(Isolate* isolate) { | |
| 212 ToLengthStub stub(isolate); | |
| 213 return make_callable(stub); | |
| 214 } | |
| 215 | |
| 216 // static | |
| 217 Callable CodeFactory::ToObject(Isolate* isolate) { | |
| 218 ToObjectStub stub(isolate); | |
| 219 return make_callable(stub); | |
| 220 } | |
| 221 | |
| 222 // static | |
| 223 Callable CodeFactory::NonPrimitiveToPrimitive(Isolate* isolate, | 193 Callable CodeFactory::NonPrimitiveToPrimitive(Isolate* isolate, |
| 224 ToPrimitiveHint hint) { | 194 ToPrimitiveHint hint) { |
| 225 return Callable(isolate->builtins()->NonPrimitiveToPrimitive(hint), | 195 return Callable(isolate->builtins()->NonPrimitiveToPrimitive(hint), |
| 226 TypeConversionDescriptor(isolate)); | 196 TypeConversionDescriptor(isolate)); |
| 227 } | 197 } |
| 228 | 198 |
| 229 // static | 199 // static |
| 230 Callable CodeFactory::OrdinaryToPrimitive(Isolate* isolate, | 200 Callable CodeFactory::OrdinaryToPrimitive(Isolate* isolate, |
| 231 OrdinaryToPrimitiveHint hint) { | 201 OrdinaryToPrimitiveHint hint) { |
| 232 return Callable(isolate->builtins()->OrdinaryToPrimitive(hint), | 202 return Callable(isolate->builtins()->OrdinaryToPrimitive(hint), |
| (...skipping 11 matching lines...) Expand all Loading... |
| 244 RegExpConstructResultStub stub(isolate); | 214 RegExpConstructResultStub stub(isolate); |
| 245 return make_callable(stub); | 215 return make_callable(stub); |
| 246 } | 216 } |
| 247 | 217 |
| 248 // static | 218 // static |
| 249 Callable CodeFactory::RegExpExec(Isolate* isolate) { | 219 Callable CodeFactory::RegExpExec(Isolate* isolate) { |
| 250 RegExpExecStub stub(isolate); | 220 RegExpExecStub stub(isolate); |
| 251 return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor()); | 221 return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor()); |
| 252 } | 222 } |
| 253 | 223 |
| 254 // static | 224 #define DECLARE_TFS(Name, Kind, Extra, InterfaceDescriptor) \ |
| 255 Callable CodeFactory::Add(Isolate* isolate) { | 225 typedef InterfaceDescriptor##Descriptor Name##Descriptor; |
| 256 AddStub stub(isolate); | 226 BUILTIN_LIST(IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN, DECLARE_TFS, |
| 257 return make_callable(stub); | 227 IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN) |
| 258 } | 228 #undef DECLARE_TFS |
| 259 | 229 |
| 260 // static | 230 #define TFS_BUILTIN(Name) \ |
| 261 Callable CodeFactory::Subtract(Isolate* isolate) { | 231 Callable CodeFactory::Name(Isolate* isolate) { \ |
| 262 SubtractStub stub(isolate); | 232 Handle<Code> code(isolate->builtins()->Name()); \ |
| 263 return make_callable(stub); | 233 return Callable(code, Name##Descriptor(isolate)); \ |
| 264 } | 234 } |
| 265 | 235 |
| 266 // static | 236 TFS_BUILTIN(ToString) |
| 267 Callable CodeFactory::Multiply(Isolate* isolate) { | 237 TFS_BUILTIN(Add) |
| 268 MultiplyStub stub(isolate); | 238 TFS_BUILTIN(Subtract) |
| 269 return make_callable(stub); | 239 TFS_BUILTIN(Multiply) |
| 270 } | 240 TFS_BUILTIN(Divide) |
| 271 | 241 TFS_BUILTIN(Modulus) |
| 272 // static | 242 TFS_BUILTIN(BitwiseAnd) |
| 273 Callable CodeFactory::Divide(Isolate* isolate) { | 243 TFS_BUILTIN(BitwiseOr) |
| 274 DivideStub stub(isolate); | 244 TFS_BUILTIN(BitwiseXor) |
| 275 return make_callable(stub); | 245 TFS_BUILTIN(ShiftLeft) |
| 276 } | 246 TFS_BUILTIN(ShiftRight) |
| 277 | 247 TFS_BUILTIN(ShiftRightLogical) |
| 278 // static | 248 TFS_BUILTIN(LessThan) |
| 279 Callable CodeFactory::Modulus(Isolate* isolate) { | 249 TFS_BUILTIN(LessThanOrEqual) |
| 280 ModulusStub stub(isolate); | 250 TFS_BUILTIN(GreaterThan) |
| 281 return make_callable(stub); | 251 TFS_BUILTIN(GreaterThanOrEqual) |
| 282 } | 252 TFS_BUILTIN(Equal) |
| 283 | 253 TFS_BUILTIN(NotEqual) |
| 284 // static | 254 TFS_BUILTIN(StrictEqual) |
| 285 Callable CodeFactory::ShiftRight(Isolate* isolate) { | 255 TFS_BUILTIN(StrictNotEqual) |
| 286 ShiftRightStub stub(isolate); | 256 TFS_BUILTIN(HasProperty) |
| 287 return make_callable(stub); | 257 TFS_BUILTIN(ToInteger) |
| 288 } | 258 TFS_BUILTIN(ToLength) |
| 289 | 259 TFS_BUILTIN(ToObject) |
| 290 // static | 260 TFS_BUILTIN(Typeof) |
| 291 Callable CodeFactory::ShiftRightLogical(Isolate* isolate) { | 261 TFS_BUILTIN(InstanceOf) |
| 292 ShiftRightLogicalStub stub(isolate); | 262 TFS_BUILTIN(ForInFilter) |
| 293 return make_callable(stub); | |
| 294 } | |
| 295 | |
| 296 // static | |
| 297 Callable CodeFactory::ShiftLeft(Isolate* isolate) { | |
| 298 ShiftLeftStub stub(isolate); | |
| 299 return make_callable(stub); | |
| 300 } | |
| 301 | |
| 302 // static | |
| 303 Callable CodeFactory::BitwiseAnd(Isolate* isolate) { | |
| 304 BitwiseAndStub stub(isolate); | |
| 305 return make_callable(stub); | |
| 306 } | |
| 307 | |
| 308 // static | |
| 309 Callable CodeFactory::BitwiseOr(Isolate* isolate) { | |
| 310 BitwiseOrStub stub(isolate); | |
| 311 return make_callable(stub); | |
| 312 } | |
| 313 | |
| 314 // static | |
| 315 Callable CodeFactory::BitwiseXor(Isolate* isolate) { | |
| 316 BitwiseXorStub stub(isolate); | |
| 317 return make_callable(stub); | |
| 318 } | |
| 319 | 263 |
| 320 // static | 264 // static |
| 321 Callable CodeFactory::Inc(Isolate* isolate) { | 265 Callable CodeFactory::Inc(Isolate* isolate) { |
| 322 IncStub stub(isolate); | 266 IncStub stub(isolate); |
| 323 return make_callable(stub); | 267 return make_callable(stub); |
| 324 } | 268 } |
| 325 | 269 |
| 326 // static | 270 // static |
| 327 Callable CodeFactory::Dec(Isolate* isolate) { | 271 Callable CodeFactory::Dec(Isolate* isolate) { |
| 328 DecStub stub(isolate); | 272 DecStub stub(isolate); |
| 329 return make_callable(stub); | 273 return make_callable(stub); |
| 330 } | 274 } |
| 331 | 275 |
| 332 // static | 276 // static |
| 333 Callable CodeFactory::LessThan(Isolate* isolate) { | |
| 334 LessThanStub stub(isolate); | |
| 335 return make_callable(stub); | |
| 336 } | |
| 337 | |
| 338 // static | |
| 339 Callable CodeFactory::LessThanOrEqual(Isolate* isolate) { | |
| 340 LessThanOrEqualStub stub(isolate); | |
| 341 return make_callable(stub); | |
| 342 } | |
| 343 | |
| 344 // static | |
| 345 Callable CodeFactory::GreaterThan(Isolate* isolate) { | |
| 346 GreaterThanStub stub(isolate); | |
| 347 return make_callable(stub); | |
| 348 } | |
| 349 | |
| 350 // static | |
| 351 Callable CodeFactory::GreaterThanOrEqual(Isolate* isolate) { | |
| 352 GreaterThanOrEqualStub stub(isolate); | |
| 353 return make_callable(stub); | |
| 354 } | |
| 355 | |
| 356 // static | |
| 357 Callable CodeFactory::Equal(Isolate* isolate) { | |
| 358 EqualStub stub(isolate); | |
| 359 return make_callable(stub); | |
| 360 } | |
| 361 | |
| 362 // static | |
| 363 Callable CodeFactory::NotEqual(Isolate* isolate) { | |
| 364 NotEqualStub stub(isolate); | |
| 365 return make_callable(stub); | |
| 366 } | |
| 367 | |
| 368 // static | |
| 369 Callable CodeFactory::StrictEqual(Isolate* isolate) { | |
| 370 StrictEqualStub stub(isolate); | |
| 371 return make_callable(stub); | |
| 372 } | |
| 373 | |
| 374 // static | |
| 375 Callable CodeFactory::StrictNotEqual(Isolate* isolate) { | |
| 376 StrictNotEqualStub stub(isolate); | |
| 377 return make_callable(stub); | |
| 378 } | |
| 379 | |
| 380 // static | |
| 381 Callable CodeFactory::StringAdd(Isolate* isolate, StringAddFlags flags, | 277 Callable CodeFactory::StringAdd(Isolate* isolate, StringAddFlags flags, |
| 382 PretenureFlag pretenure_flag) { | 278 PretenureFlag pretenure_flag) { |
| 383 StringAddStub stub(isolate, flags, pretenure_flag); | 279 StringAddStub stub(isolate, flags, pretenure_flag); |
| 384 return make_callable(stub); | 280 return make_callable(stub); |
| 385 } | 281 } |
| 386 | 282 |
| 387 // static | 283 // static |
| 388 Callable CodeFactory::StringCompare(Isolate* isolate, Token::Value token) { | 284 Callable CodeFactory::StringCompare(Isolate* isolate, Token::Value token) { |
| 389 switch (token) { | 285 switch (token) { |
| 390 case Token::EQ: | 286 case Token::EQ: |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor()); | 346 return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor()); |
| 451 } | 347 } |
| 452 | 348 |
| 453 // static | 349 // static |
| 454 Callable CodeFactory::ResumeGenerator(Isolate* isolate) { | 350 Callable CodeFactory::ResumeGenerator(Isolate* isolate) { |
| 455 return Callable(isolate->builtins()->ResumeGeneratorTrampoline(), | 351 return Callable(isolate->builtins()->ResumeGeneratorTrampoline(), |
| 456 ResumeGeneratorDescriptor(isolate)); | 352 ResumeGeneratorDescriptor(isolate)); |
| 457 } | 353 } |
| 458 | 354 |
| 459 // static | 355 // static |
| 460 Callable CodeFactory::Typeof(Isolate* isolate) { | |
| 461 TypeofStub stub(isolate); | |
| 462 return make_callable(stub); | |
| 463 } | |
| 464 | |
| 465 // static | |
| 466 Callable CodeFactory::FastCloneRegExp(Isolate* isolate) { | 356 Callable CodeFactory::FastCloneRegExp(Isolate* isolate) { |
| 467 FastCloneRegExpStub stub(isolate); | 357 FastCloneRegExpStub stub(isolate); |
| 468 return make_callable(stub); | 358 return make_callable(stub); |
| 469 } | 359 } |
| 470 | 360 |
| 471 // static | 361 // static |
| 472 Callable CodeFactory::FastCloneShallowArray(Isolate* isolate) { | 362 Callable CodeFactory::FastCloneShallowArray(Isolate* isolate) { |
| 473 // TODO(mstarzinger): Thread through AllocationSiteMode at some point. | 363 // TODO(mstarzinger): Thread through AllocationSiteMode at some point. |
| 474 FastCloneShallowArrayStub stub(isolate, DONT_TRACK_ALLOCATION_SITE); | 364 FastCloneShallowArrayStub stub(isolate, DONT_TRACK_ALLOCATION_SITE); |
| 475 return make_callable(stub); | 365 return make_callable(stub); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 ConstructTrampolineDescriptor(isolate)); | 468 ConstructTrampolineDescriptor(isolate)); |
| 579 } | 469 } |
| 580 | 470 |
| 581 // static | 471 // static |
| 582 Callable CodeFactory::ConstructFunction(Isolate* isolate) { | 472 Callable CodeFactory::ConstructFunction(Isolate* isolate) { |
| 583 return Callable(isolate->builtins()->ConstructFunction(), | 473 return Callable(isolate->builtins()->ConstructFunction(), |
| 584 ConstructTrampolineDescriptor(isolate)); | 474 ConstructTrampolineDescriptor(isolate)); |
| 585 } | 475 } |
| 586 | 476 |
| 587 // static | 477 // static |
| 588 Callable CodeFactory::HasProperty(Isolate* isolate) { | |
| 589 HasPropertyStub stub(isolate); | |
| 590 return make_callable(stub); | |
| 591 } | |
| 592 | |
| 593 // static | |
| 594 Callable CodeFactory::ForInFilter(Isolate* isolate) { | |
| 595 ForInFilterStub stub(isolate); | |
| 596 return make_callable(stub); | |
| 597 } | |
| 598 | |
| 599 // static | |
| 600 Callable CodeFactory::InterpreterPushArgsAndCall(Isolate* isolate, | 478 Callable CodeFactory::InterpreterPushArgsAndCall(Isolate* isolate, |
| 601 TailCallMode tail_call_mode, | 479 TailCallMode tail_call_mode, |
| 602 CallableType function_type) { | 480 CallableType function_type) { |
| 603 return Callable(isolate->builtins()->InterpreterPushArgsAndCall( | 481 return Callable(isolate->builtins()->InterpreterPushArgsAndCall( |
| 604 tail_call_mode, function_type), | 482 tail_call_mode, function_type), |
| 605 InterpreterPushArgsAndCallDescriptor(isolate)); | 483 InterpreterPushArgsAndCallDescriptor(isolate)); |
| 606 } | 484 } |
| 607 | 485 |
| 608 // static | 486 // static |
| 609 Callable CodeFactory::InterpreterPushArgsAndConstruct( | 487 Callable CodeFactory::InterpreterPushArgsAndConstruct( |
| (...skipping 18 matching lines...) Expand all Loading... |
| 628 } | 506 } |
| 629 | 507 |
| 630 // static | 508 // static |
| 631 Callable CodeFactory::InterpreterOnStackReplacement(Isolate* isolate) { | 509 Callable CodeFactory::InterpreterOnStackReplacement(Isolate* isolate) { |
| 632 return Callable(isolate->builtins()->InterpreterOnStackReplacement(), | 510 return Callable(isolate->builtins()->InterpreterOnStackReplacement(), |
| 633 ContextOnlyDescriptor(isolate)); | 511 ContextOnlyDescriptor(isolate)); |
| 634 } | 512 } |
| 635 | 513 |
| 636 } // namespace internal | 514 } // namespace internal |
| 637 } // namespace v8 | 515 } // namespace v8 |
| OLD | NEW |