Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: src/objects.h

Issue 1292753007: [es6] Parameter scopes for sloppy eval (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_OBJECTS_H_ 5 #ifndef V8_OBJECTS_H_
6 #define V8_OBJECTS_H_ 6 #define V8_OBJECTS_H_
7 7
8 #include <iosfwd> 8 #include <iosfwd>
9 9
10 #include "src/allocation.h" 10 #include "src/allocation.h"
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 V(TYPE_SWITCH_INFO_TYPE) \ 415 V(TYPE_SWITCH_INFO_TYPE) \
416 V(ALLOCATION_MEMENTO_TYPE) \ 416 V(ALLOCATION_MEMENTO_TYPE) \
417 V(ALLOCATION_SITE_TYPE) \ 417 V(ALLOCATION_SITE_TYPE) \
418 V(SCRIPT_TYPE) \ 418 V(SCRIPT_TYPE) \
419 V(CODE_CACHE_TYPE) \ 419 V(CODE_CACHE_TYPE) \
420 V(POLYMORPHIC_CODE_CACHE_TYPE) \ 420 V(POLYMORPHIC_CODE_CACHE_TYPE) \
421 V(TYPE_FEEDBACK_INFO_TYPE) \ 421 V(TYPE_FEEDBACK_INFO_TYPE) \
422 V(ALIASED_ARGUMENTS_ENTRY_TYPE) \ 422 V(ALIASED_ARGUMENTS_ENTRY_TYPE) \
423 V(BOX_TYPE) \ 423 V(BOX_TYPE) \
424 V(PROTOTYPE_INFO_TYPE) \ 424 V(PROTOTYPE_INFO_TYPE) \
425 V(SLOPPY_BLOCK_WITH_EVAL_CONTEXT_EXTENSION_TYPE) \
425 \ 426 \
426 V(FIXED_ARRAY_TYPE) \ 427 V(FIXED_ARRAY_TYPE) \
427 V(FIXED_DOUBLE_ARRAY_TYPE) \ 428 V(FIXED_DOUBLE_ARRAY_TYPE) \
428 V(SHARED_FUNCTION_INFO_TYPE) \ 429 V(SHARED_FUNCTION_INFO_TYPE) \
429 V(WEAK_CELL_TYPE) \ 430 V(WEAK_CELL_TYPE) \
430 \ 431 \
431 V(JS_MESSAGE_OBJECT_TYPE) \ 432 V(JS_MESSAGE_OBJECT_TYPE) \
432 \ 433 \
433 V(JS_VALUE_TYPE) \ 434 V(JS_VALUE_TYPE) \
434 V(JS_DATE_TYPE) \ 435 V(JS_DATE_TYPE) \
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 V(TYPE_SWITCH_INFO, TypeSwitchInfo, type_switch_info) \ 532 V(TYPE_SWITCH_INFO, TypeSwitchInfo, type_switch_info) \
532 V(SCRIPT, Script, script) \ 533 V(SCRIPT, Script, script) \
533 V(ALLOCATION_SITE, AllocationSite, allocation_site) \ 534 V(ALLOCATION_SITE, AllocationSite, allocation_site) \
534 V(ALLOCATION_MEMENTO, AllocationMemento, allocation_memento) \ 535 V(ALLOCATION_MEMENTO, AllocationMemento, allocation_memento) \
535 V(CODE_CACHE, CodeCache, code_cache) \ 536 V(CODE_CACHE, CodeCache, code_cache) \
536 V(POLYMORPHIC_CODE_CACHE, PolymorphicCodeCache, polymorphic_code_cache) \ 537 V(POLYMORPHIC_CODE_CACHE, PolymorphicCodeCache, polymorphic_code_cache) \
537 V(TYPE_FEEDBACK_INFO, TypeFeedbackInfo, type_feedback_info) \ 538 V(TYPE_FEEDBACK_INFO, TypeFeedbackInfo, type_feedback_info) \
538 V(ALIASED_ARGUMENTS_ENTRY, AliasedArgumentsEntry, aliased_arguments_entry) \ 539 V(ALIASED_ARGUMENTS_ENTRY, AliasedArgumentsEntry, aliased_arguments_entry) \
539 V(DEBUG_INFO, DebugInfo, debug_info) \ 540 V(DEBUG_INFO, DebugInfo, debug_info) \
540 V(BREAK_POINT_INFO, BreakPointInfo, break_point_info) \ 541 V(BREAK_POINT_INFO, BreakPointInfo, break_point_info) \
541 V(PROTOTYPE_INFO, PrototypeInfo, prototype_info) 542 V(PROTOTYPE_INFO, PrototypeInfo, prototype_info) \
543 V(SLOPPY_BLOCK_WITH_EVAL_CONTEXT_EXTENSION, \
544 SloppyBlockWithEvalContextExtension, \
545 sloppy_block_with_eval_context_extension)
542 546
543 // We use the full 8 bits of the instance_type field to encode heap object 547 // We use the full 8 bits of the instance_type field to encode heap object
544 // instance types. The high-order bit (bit 7) is set if the object is not a 548 // instance types. The high-order bit (bit 7) is set if the object is not a
545 // string, and cleared if it is a string. 549 // string, and cleared if it is a string.
546 const uint32_t kIsNotStringMask = 0x80; 550 const uint32_t kIsNotStringMask = 0x80;
547 const uint32_t kStringTag = 0x0; 551 const uint32_t kStringTag = 0x0;
548 const uint32_t kNotStringTag = 0x80; 552 const uint32_t kNotStringTag = 0x80;
549 553
550 // Bit 6 indicates that the object is an internalized string (if set) or not. 554 // Bit 6 indicates that the object is an internalized string (if set) or not.
551 // Bit 7 has to be clear as well. 555 // Bit 7 has to be clear as well.
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 ALIASED_ARGUMENTS_ENTRY_TYPE, 713 ALIASED_ARGUMENTS_ENTRY_TYPE,
710 BOX_TYPE, 714 BOX_TYPE,
711 DEBUG_INFO_TYPE, 715 DEBUG_INFO_TYPE,
712 BREAK_POINT_INFO_TYPE, 716 BREAK_POINT_INFO_TYPE,
713 FIXED_ARRAY_TYPE, 717 FIXED_ARRAY_TYPE,
714 SHARED_FUNCTION_INFO_TYPE, 718 SHARED_FUNCTION_INFO_TYPE,
715 CELL_TYPE, 719 CELL_TYPE,
716 WEAK_CELL_TYPE, 720 WEAK_CELL_TYPE,
717 PROPERTY_CELL_TYPE, 721 PROPERTY_CELL_TYPE,
718 PROTOTYPE_INFO_TYPE, 722 PROTOTYPE_INFO_TYPE,
723 SLOPPY_BLOCK_WITH_EVAL_CONTEXT_EXTENSION_TYPE,
719 724
720 // All the following types are subtypes of JSReceiver, which corresponds to 725 // All the following types are subtypes of JSReceiver, which corresponds to
721 // objects in the JS sense. The first and the last type in this range are 726 // objects in the JS sense. The first and the last type in this range are
722 // the two forms of function. This organization enables using the same 727 // the two forms of function. This organization enables using the same
723 // compares for checking the JS_RECEIVER/SPEC_OBJECT range and the 728 // compares for checking the JS_RECEIVER/SPEC_OBJECT range and the
724 // NONCALLABLE_JS_OBJECT range. 729 // NONCALLABLE_JS_OBJECT range.
725 JS_FUNCTION_PROXY_TYPE, // FIRST_JS_RECEIVER_TYPE, FIRST_JS_PROXY_TYPE 730 JS_FUNCTION_PROXY_TYPE, // FIRST_JS_RECEIVER_TYPE, FIRST_JS_PROXY_TYPE
726 JS_PROXY_TYPE, // LAST_JS_PROXY_TYPE 731 JS_PROXY_TYPE, // LAST_JS_PROXY_TYPE
727 JS_VALUE_TYPE, // FIRST_JS_OBJECT_TYPE 732 JS_VALUE_TYPE, // FIRST_JS_OBJECT_TYPE
728 JS_MESSAGE_OBJECT_TYPE, 733 JS_MESSAGE_OBJECT_TYPE,
(...skipping 3046 matching lines...) Expand 10 before | Expand all | Expand 10 after
3775 3780
3776 // Return the type of this scope. 3781 // Return the type of this scope.
3777 ScopeType scope_type(); 3782 ScopeType scope_type();
3778 3783
3779 // Does this scope call eval? 3784 // Does this scope call eval?
3780 bool CallsEval(); 3785 bool CallsEval();
3781 3786
3782 // Return the language mode of this scope. 3787 // Return the language mode of this scope.
3783 LanguageMode language_mode(); 3788 LanguageMode language_mode();
3784 3789
3790 // True if this scope is a (var) declaration scope.
3791 bool is_declaration_scope();
3792
3785 // Does this scope make a sloppy eval call? 3793 // Does this scope make a sloppy eval call?
3786 bool CallsSloppyEval() { return CallsEval() && is_sloppy(language_mode()); } 3794 bool CallsSloppyEval() { return CallsEval() && is_sloppy(language_mode()); }
3787 3795
3788 // Return the total number of locals allocated on the stack and in the 3796 // Return the total number of locals allocated on the stack and in the
3789 // context. This includes the parameters that are allocated in the context. 3797 // context. This includes the parameters that are allocated in the context.
3790 int LocalCount(); 3798 int LocalCount();
3791 3799
3792 // Return the number of stack slots for code. This number consists of two 3800 // Return the number of stack slots for code. This number consists of two
3793 // parts: 3801 // parts:
3794 // 1. One stack slot per stack allocated local. 3802 // 1. One stack slot per stack allocated local.
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
3998 // Used for the function name variable for named function expressions, and for 4006 // Used for the function name variable for named function expressions, and for
3999 // the receiver. 4007 // the receiver.
4000 enum VariableAllocationInfo { NONE, STACK, CONTEXT, UNUSED }; 4008 enum VariableAllocationInfo { NONE, STACK, CONTEXT, UNUSED };
4001 4009
4002 // Properties of scopes. 4010 // Properties of scopes.
4003 class ScopeTypeField : public BitField<ScopeType, 0, 4> {}; 4011 class ScopeTypeField : public BitField<ScopeType, 0, 4> {};
4004 class CallsEvalField : public BitField<bool, ScopeTypeField::kNext, 1> {}; 4012 class CallsEvalField : public BitField<bool, ScopeTypeField::kNext, 1> {};
4005 STATIC_ASSERT(LANGUAGE_END == 3); 4013 STATIC_ASSERT(LANGUAGE_END == 3);
4006 class LanguageModeField 4014 class LanguageModeField
4007 : public BitField<LanguageMode, CallsEvalField::kNext, 2> {}; 4015 : public BitField<LanguageMode, CallsEvalField::kNext, 2> {};
4016 class DeclarationScopeField
4017 : public BitField<bool, LanguageModeField::kNext, 1> {};
4008 class ReceiverVariableField 4018 class ReceiverVariableField
4009 : public BitField<VariableAllocationInfo, LanguageModeField::kNext, 2> {}; 4019 : public BitField<VariableAllocationInfo, DeclarationScopeField::kNext,
4020 2> {};
4010 class FunctionVariableField 4021 class FunctionVariableField
4011 : public BitField<VariableAllocationInfo, ReceiverVariableField::kNext, 4022 : public BitField<VariableAllocationInfo, ReceiverVariableField::kNext,
4012 2> {}; 4023 2> {};
4013 class FunctionVariableMode 4024 class FunctionVariableMode
4014 : public BitField<VariableMode, FunctionVariableField::kNext, 3> {}; 4025 : public BitField<VariableMode, FunctionVariableField::kNext, 3> {};
4015 class AsmModuleField : public BitField<bool, FunctionVariableMode::kNext, 1> { 4026 class AsmModuleField : public BitField<bool, FunctionVariableMode::kNext, 1> {
4016 }; 4027 };
4017 class AsmFunctionField : public BitField<bool, AsmModuleField::kNext, 1> {}; 4028 class AsmFunctionField : public BitField<bool, AsmModuleField::kNext, 1> {};
4018 class HasSimpleParametersField 4029 class HasSimpleParametersField
4019 : public BitField<bool, AsmFunctionField::kNext, 1> {}; 4030 : public BitField<bool, AsmFunctionField::kNext, 1> {};
(...skipping 1841 matching lines...) Expand 10 before | Expand all | Expand 10 after
5861 static const int kRegistrySlotOffset = kPrototypeUsersOffset + kPointerSize; 5872 static const int kRegistrySlotOffset = kPrototypeUsersOffset + kPointerSize;
5862 static const int kValidityCellOffset = kRegistrySlotOffset + kPointerSize; 5873 static const int kValidityCellOffset = kRegistrySlotOffset + kPointerSize;
5863 static const int kConstructorNameOffset = kValidityCellOffset + kPointerSize; 5874 static const int kConstructorNameOffset = kValidityCellOffset + kPointerSize;
5864 static const int kSize = kConstructorNameOffset + kPointerSize; 5875 static const int kSize = kConstructorNameOffset + kPointerSize;
5865 5876
5866 private: 5877 private:
5867 DISALLOW_IMPLICIT_CONSTRUCTORS(PrototypeInfo); 5878 DISALLOW_IMPLICIT_CONSTRUCTORS(PrototypeInfo);
5868 }; 5879 };
5869 5880
5870 5881
5882 // Pair used to store both a ScopeInfo and an extension object in the extension
5883 // slot of a block context. Needed in the rare case where a declaration block
5884 // scope (a "varblock" as used to desugar parameter destructuring) also contains
5885 // a sloppy direct eval. (In no other case both are needed at the same time.)
5886 class SloppyBlockWithEvalContextExtension : public Struct {
5887 public:
5888 // [scope_info]: Scope info.
5889 DECL_ACCESSORS(scope_info, ScopeInfo)
5890 // [extension]: Extension object.
5891 DECL_ACCESSORS(extension, JSObject)
5892
5893 DECLARE_CAST(SloppyBlockWithEvalContextExtension)
5894
5895 // Dispatched behavior.
5896 DECLARE_PRINTER(SloppyBlockWithEvalContextExtension)
5897 DECLARE_VERIFIER(SloppyBlockWithEvalContextExtension)
5898
5899 static const int kScopeInfoOffset = HeapObject::kHeaderSize;
5900 static const int kExtensionOffset = kScopeInfoOffset + kPointerSize;
5901 static const int kSize = kExtensionOffset + kPointerSize;
5902
5903 private:
5904 DISALLOW_IMPLICIT_CONSTRUCTORS(SloppyBlockWithEvalContextExtension);
5905 };
5906
5907
5871 // Script describes a script which has been added to the VM. 5908 // Script describes a script which has been added to the VM.
5872 class Script: public Struct { 5909 class Script: public Struct {
5873 public: 5910 public:
5874 // Script types. 5911 // Script types.
5875 enum Type { 5912 enum Type {
5876 TYPE_NATIVE = 0, 5913 TYPE_NATIVE = 0,
5877 TYPE_EXTENSION = 1, 5914 TYPE_EXTENSION = 1,
5878 TYPE_NORMAL = 2 5915 TYPE_NORMAL = 2
5879 }; 5916 };
5880 5917
(...skipping 4374 matching lines...) Expand 10 before | Expand all | Expand 10 after
10255 } else { 10292 } else {
10256 value &= ~(1 << bit_position); 10293 value &= ~(1 << bit_position);
10257 } 10294 }
10258 return value; 10295 return value;
10259 } 10296 }
10260 }; 10297 };
10261 10298
10262 } } // namespace v8::internal 10299 } } // namespace v8::internal
10263 10300
10264 #endif // V8_OBJECTS_H_ 10301 #endif // V8_OBJECTS_H_
OLDNEW
« src/contexts.cc ('K') | « src/hydrogen.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698