| 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 #ifndef V8_CODE_STUBS_H_ | 5 #ifndef V8_CODE_STUBS_H_ |
| 6 #define V8_CODE_STUBS_H_ | 6 #define V8_CODE_STUBS_H_ |
| 7 | 7 |
| 8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
| 9 #include "src/assembler.h" | 9 #include "src/assembler.h" |
| 10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
| 11 #include "src/globals.h" | 11 #include "src/globals.h" |
| 12 #include "src/ic/ic.h" | 12 #include "src/ic/ic.h" |
| 13 #include "src/ic/ic-conventions.h" | |
| 14 #include "src/interface-descriptors.h" | 13 #include "src/interface-descriptors.h" |
| 15 #include "src/macro-assembler.h" | 14 #include "src/macro-assembler.h" |
| 16 #include "src/ostreams.h" | 15 #include "src/ostreams.h" |
| 17 | 16 |
| 18 namespace v8 { | 17 namespace v8 { |
| 19 namespace internal { | 18 namespace internal { |
| 20 | 19 |
| 21 // List of code stubs used on all platforms. | 20 // List of code stubs used on all platforms. |
| 22 #define CODE_STUB_LIST_ALL_PLATFORMS(V) \ | 21 #define CODE_STUB_LIST_ALL_PLATFORMS(V) \ |
| 23 V(CallFunction) \ | 22 V(CallFunction) \ |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 | 285 |
| 287 enum StubFunctionMode { NOT_JS_FUNCTION_STUB_MODE, JS_FUNCTION_STUB_MODE }; | 286 enum StubFunctionMode { NOT_JS_FUNCTION_STUB_MODE, JS_FUNCTION_STUB_MODE }; |
| 288 enum HandlerArgumentsMode { DONT_PASS_ARGUMENTS, PASS_ARGUMENTS }; | 287 enum HandlerArgumentsMode { DONT_PASS_ARGUMENTS, PASS_ARGUMENTS }; |
| 289 | 288 |
| 290 | 289 |
| 291 class CodeStubInterfaceDescriptor { | 290 class CodeStubInterfaceDescriptor { |
| 292 public: | 291 public: |
| 293 CodeStubInterfaceDescriptor(); | 292 CodeStubInterfaceDescriptor(); |
| 294 | 293 |
| 295 void Initialize(CodeStub::Major major, | 294 void Initialize(CodeStub::Major major, |
| 296 CallInterfaceDescriptor* call_descriptor, | 295 CallInterfaceDescriptor call_descriptor, |
| 297 Address deoptimization_handler = NULL, | 296 Address deoptimization_handler = NULL, |
| 298 int hint_stack_parameter_count = -1, | 297 int hint_stack_parameter_count = -1, |
| 299 StubFunctionMode function_mode = NOT_JS_FUNCTION_STUB_MODE); | 298 StubFunctionMode function_mode = NOT_JS_FUNCTION_STUB_MODE); |
| 300 void Initialize(CodeStub::Major major, | 299 void Initialize(CodeStub::Major major, |
| 301 CallInterfaceDescriptor* call_descriptor, | 300 CallInterfaceDescriptor call_descriptor, |
| 302 Register stack_parameter_count, | 301 Register stack_parameter_count, |
| 303 Address deoptimization_handler = NULL, | 302 Address deoptimization_handler = NULL, |
| 304 int hint_stack_parameter_count = -1, | 303 int hint_stack_parameter_count = -1, |
| 305 StubFunctionMode function_mode = NOT_JS_FUNCTION_STUB_MODE, | 304 StubFunctionMode function_mode = NOT_JS_FUNCTION_STUB_MODE, |
| 306 HandlerArgumentsMode handler_mode = DONT_PASS_ARGUMENTS); | 305 HandlerArgumentsMode handler_mode = DONT_PASS_ARGUMENTS); |
| 307 | 306 |
| 308 void SetMissHandler(ExternalReference handler) { | 307 void SetMissHandler(ExternalReference handler) { |
| 309 miss_handler_ = handler; | 308 miss_handler_ = handler; |
| 310 has_miss_handler_ = true; | 309 has_miss_handler_ = true; |
| 311 // Our miss handler infrastructure doesn't currently support | 310 // Our miss handler infrastructure doesn't currently support |
| 312 // variable stack parameter counts. | 311 // variable stack parameter counts. |
| 313 DCHECK(!stack_parameter_count_.is_valid()); | 312 DCHECK(!stack_parameter_count_.is_valid()); |
| 314 } | 313 } |
| 315 | 314 |
| 316 bool IsInitialized() const { return call_descriptor_ != NULL; } | 315 bool IsInitialized() const { return call_descriptor_.IsInitialized(); } |
| 317 | 316 |
| 318 CallInterfaceDescriptor* call_descriptor() const { return call_descriptor_; } | 317 CallInterfaceDescriptor call_descriptor() const { return call_descriptor_; } |
| 319 | 318 |
| 320 int GetEnvironmentLength() const { | 319 int GetEnvironmentLength() const { |
| 321 return call_descriptor()->GetEnvironmentLength(); | 320 return call_descriptor().GetEnvironmentLength(); |
| 322 } | 321 } |
| 323 | 322 |
| 324 int GetRegisterParameterCount() const { | 323 int GetRegisterParameterCount() const { |
| 325 return call_descriptor()->GetRegisterParameterCount(); | 324 return call_descriptor().GetRegisterParameterCount(); |
| 326 } | 325 } |
| 327 | 326 |
| 328 Register GetParameterRegister(int index) const { | 327 Register GetParameterRegister(int index) const { |
| 329 return call_descriptor()->GetParameterRegister(index); | 328 return call_descriptor().GetParameterRegister(index); |
| 330 } | 329 } |
| 331 | 330 |
| 332 Representation GetParameterRepresentation(int index) const { | 331 Representation GetParameterRepresentation(int index) const { |
| 333 return call_descriptor()->GetParameterRepresentation(index); | 332 return call_descriptor().GetParameterRepresentation(index); |
| 334 } | 333 } |
| 335 | 334 |
| 336 int GetEnvironmentParameterCount() const { | 335 int GetEnvironmentParameterCount() const { |
| 337 return call_descriptor()->GetEnvironmentParameterCount(); | 336 return call_descriptor().GetEnvironmentParameterCount(); |
| 338 } | 337 } |
| 339 | 338 |
| 340 Register GetEnvironmentParameterRegister(int index) const { | 339 Register GetEnvironmentParameterRegister(int index) const { |
| 341 return call_descriptor()->GetEnvironmentParameterRegister(index); | 340 return call_descriptor().GetEnvironmentParameterRegister(index); |
| 342 } | 341 } |
| 343 | 342 |
| 344 Representation GetEnvironmentParameterRepresentation(int index) const { | 343 Representation GetEnvironmentParameterRepresentation(int index) const { |
| 345 return call_descriptor()->GetEnvironmentParameterRepresentation(index); | 344 return call_descriptor().GetEnvironmentParameterRepresentation(index); |
| 346 } | 345 } |
| 347 | 346 |
| 348 ExternalReference miss_handler() const { | 347 ExternalReference miss_handler() const { |
| 349 DCHECK(has_miss_handler_); | 348 DCHECK(has_miss_handler_); |
| 350 return miss_handler_; | 349 return miss_handler_; |
| 351 } | 350 } |
| 352 | 351 |
| 353 bool has_miss_handler() const { | 352 bool has_miss_handler() const { |
| 354 return has_miss_handler_; | 353 return has_miss_handler_; |
| 355 } | 354 } |
| 356 | 355 |
| 357 bool IsEnvironmentParameterCountRegister(int index) const { | 356 bool IsEnvironmentParameterCountRegister(int index) const { |
| 358 return call_descriptor()->GetEnvironmentParameterRegister(index).is( | 357 return call_descriptor().GetEnvironmentParameterRegister(index).is( |
| 359 stack_parameter_count_); | 358 stack_parameter_count_); |
| 360 } | 359 } |
| 361 | 360 |
| 362 int GetHandlerParameterCount() const { | 361 int GetHandlerParameterCount() const { |
| 363 int params = call_descriptor()->GetEnvironmentParameterCount(); | 362 int params = call_descriptor().GetEnvironmentParameterCount(); |
| 364 if (handler_arguments_mode_ == PASS_ARGUMENTS) { | 363 if (handler_arguments_mode_ == PASS_ARGUMENTS) { |
| 365 params += 1; | 364 params += 1; |
| 366 } | 365 } |
| 367 return params; | 366 return params; |
| 368 } | 367 } |
| 369 | 368 |
| 370 int hint_stack_parameter_count() const { return hint_stack_parameter_count_; } | 369 int hint_stack_parameter_count() const { return hint_stack_parameter_count_; } |
| 371 Register stack_parameter_count() const { return stack_parameter_count_; } | 370 Register stack_parameter_count() const { return stack_parameter_count_; } |
| 372 StubFunctionMode function_mode() const { return function_mode_; } | 371 StubFunctionMode function_mode() const { return function_mode_; } |
| 373 Address deoptimization_handler() const { return deoptimization_handler_; } | 372 Address deoptimization_handler() const { return deoptimization_handler_; } |
| 374 CodeStub::Major MajorKey() const { return major_; } | 373 CodeStub::Major MajorKey() const { return major_; } |
| 375 | 374 |
| 376 private: | 375 private: |
| 377 CallInterfaceDescriptor* call_descriptor_; | 376 CallInterfaceDescriptor call_descriptor_; |
| 378 Register stack_parameter_count_; | 377 Register stack_parameter_count_; |
| 379 // If hint_stack_parameter_count_ > 0, the code stub can optimize the | 378 // If hint_stack_parameter_count_ > 0, the code stub can optimize the |
| 380 // return sequence. Default value is -1, which means it is ignored. | 379 // return sequence. Default value is -1, which means it is ignored. |
| 381 int hint_stack_parameter_count_; | 380 int hint_stack_parameter_count_; |
| 382 StubFunctionMode function_mode_; | 381 StubFunctionMode function_mode_; |
| 383 | 382 |
| 384 Address deoptimization_handler_; | 383 Address deoptimization_handler_; |
| 385 HandlerArgumentsMode handler_arguments_mode_; | 384 HandlerArgumentsMode handler_arguments_mode_; |
| 386 | 385 |
| 387 ExternalReference miss_handler_; | 386 ExternalReference miss_handler_; |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 695 kCallSiteInlineCheck = 1 << 1, | 694 kCallSiteInlineCheck = 1 << 1, |
| 696 kReturnTrueFalseObject = 1 << 2 | 695 kReturnTrueFalseObject = 1 << 2 |
| 697 }; | 696 }; |
| 698 | 697 |
| 699 InstanceofStub(Isolate* isolate, Flags flags) : PlatformCodeStub(isolate) { | 698 InstanceofStub(Isolate* isolate, Flags flags) : PlatformCodeStub(isolate) { |
| 700 minor_key_ = FlagBits::encode(flags); | 699 minor_key_ = FlagBits::encode(flags); |
| 701 } | 700 } |
| 702 | 701 |
| 703 void Generate(MacroAssembler* masm); | 702 void Generate(MacroAssembler* masm); |
| 704 | 703 |
| 705 static Register left() { return InstanceofConvention::left(); } | 704 static Register left() { return InstanceofDescriptor::left(); } |
| 706 static Register right() { return InstanceofConvention::right(); } | 705 static Register right() { return InstanceofDescriptor::right(); } |
| 707 | 706 |
| 708 virtual void InitializeInterfaceDescriptor( | 707 virtual void InitializeInterfaceDescriptor( |
| 709 CodeStubInterfaceDescriptor* descriptor); | 708 CodeStubInterfaceDescriptor* descriptor); |
| 710 | 709 |
| 711 private: | 710 private: |
| 712 virtual Major MajorKey() const OVERRIDE { return Instanceof; } | 711 virtual Major MajorKey() const OVERRIDE { return Instanceof; } |
| 713 | 712 |
| 714 Flags flags() const { return FlagBits::decode(minor_key_); } | 713 Flags flags() const { return FlagBits::decode(minor_key_); } |
| 715 | 714 |
| 716 bool HasArgsInRegisters() const { return (flags() & kArgsInRegisters) != 0; } | 715 bool HasArgsInRegisters() const { return (flags() & kArgsInRegisters) != 0; } |
| (...skipping 1815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2532 // Parameters accessed via CodeStubGraphBuilder::GetParameter() | 2531 // Parameters accessed via CodeStubGraphBuilder::GetParameter() |
| 2533 enum ParameterIndices { | 2532 enum ParameterIndices { |
| 2534 kValueIndex, | 2533 kValueIndex, |
| 2535 kMapIndex, | 2534 kMapIndex, |
| 2536 kKeyIndex, | 2535 kKeyIndex, |
| 2537 kObjectIndex, | 2536 kObjectIndex, |
| 2538 kParameterCount | 2537 kParameterCount |
| 2539 }; | 2538 }; |
| 2540 | 2539 |
| 2541 static const Register ValueRegister() { | 2540 static const Register ValueRegister() { |
| 2542 return StoreConvention::ValueRegister(); | 2541 return ElementTransitionAndStoreDescriptor::ValueRegister(); |
| 2543 } | 2542 } |
| 2544 static const Register MapRegister() { return StoreConvention::MapRegister(); } | 2543 static const Register MapRegister() { |
| 2544 return ElementTransitionAndStoreDescriptor::MapRegister(); |
| 2545 } |
| 2545 static const Register KeyRegister() { | 2546 static const Register KeyRegister() { |
| 2546 return StoreConvention::NameRegister(); | 2547 return ElementTransitionAndStoreDescriptor::NameRegister(); |
| 2547 } | 2548 } |
| 2548 static const Register ObjectRegister() { | 2549 static const Register ObjectRegister() { |
| 2549 return StoreConvention::ReceiverRegister(); | 2550 return ElementTransitionAndStoreDescriptor::ReceiverRegister(); |
| 2550 } | 2551 } |
| 2551 | 2552 |
| 2552 private: | 2553 private: |
| 2553 virtual Major MajorKey() const OVERRIDE { | 2554 virtual Major MajorKey() const OVERRIDE { |
| 2554 return ElementsTransitionAndStore; | 2555 return ElementsTransitionAndStore; |
| 2555 } | 2556 } |
| 2556 | 2557 |
| 2557 class FromBits : public BitField<ElementsKind, 0, 8> {}; | 2558 class FromBits : public BitField<ElementsKind, 0, 8> {}; |
| 2558 class ToBits : public BitField<ElementsKind, 8, 8> {}; | 2559 class ToBits : public BitField<ElementsKind, 8, 8> {}; |
| 2559 class IsJSArrayBits : public BitField<bool, 16, 1> {}; | 2560 class IsJSArrayBits : public BitField<bool, 16, 1> {}; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2622 | 2623 |
| 2623 void Generate(MacroAssembler* masm); | 2624 void Generate(MacroAssembler* masm); |
| 2624 | 2625 |
| 2625 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub); | 2626 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub); |
| 2626 }; | 2627 }; |
| 2627 | 2628 |
| 2628 | 2629 |
| 2629 } } // namespace v8::internal | 2630 } } // namespace v8::internal |
| 2630 | 2631 |
| 2631 #endif // V8_CODE_STUBS_H_ | 2632 #endif // V8_CODE_STUBS_H_ |
| OLD | NEW |