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

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: Comments 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
« no previous file with comments | « src/hydrogen.cc ('k') | src/objects.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 V(TYPE_SWITCH_INFO_TYPE) \ 384 V(TYPE_SWITCH_INFO_TYPE) \
385 V(ALLOCATION_MEMENTO_TYPE) \ 385 V(ALLOCATION_MEMENTO_TYPE) \
386 V(ALLOCATION_SITE_TYPE) \ 386 V(ALLOCATION_SITE_TYPE) \
387 V(SCRIPT_TYPE) \ 387 V(SCRIPT_TYPE) \
388 V(CODE_CACHE_TYPE) \ 388 V(CODE_CACHE_TYPE) \
389 V(POLYMORPHIC_CODE_CACHE_TYPE) \ 389 V(POLYMORPHIC_CODE_CACHE_TYPE) \
390 V(TYPE_FEEDBACK_INFO_TYPE) \ 390 V(TYPE_FEEDBACK_INFO_TYPE) \
391 V(ALIASED_ARGUMENTS_ENTRY_TYPE) \ 391 V(ALIASED_ARGUMENTS_ENTRY_TYPE) \
392 V(BOX_TYPE) \ 392 V(BOX_TYPE) \
393 V(PROTOTYPE_INFO_TYPE) \ 393 V(PROTOTYPE_INFO_TYPE) \
394 V(SLOPPY_BLOCK_WITH_EVAL_CONTEXT_EXTENSION_TYPE) \
394 \ 395 \
395 V(FIXED_ARRAY_TYPE) \ 396 V(FIXED_ARRAY_TYPE) \
396 V(FIXED_DOUBLE_ARRAY_TYPE) \ 397 V(FIXED_DOUBLE_ARRAY_TYPE) \
397 V(SHARED_FUNCTION_INFO_TYPE) \ 398 V(SHARED_FUNCTION_INFO_TYPE) \
398 V(WEAK_CELL_TYPE) \ 399 V(WEAK_CELL_TYPE) \
399 \ 400 \
400 V(JS_MESSAGE_OBJECT_TYPE) \ 401 V(JS_MESSAGE_OBJECT_TYPE) \
401 \ 402 \
402 V(JS_VALUE_TYPE) \ 403 V(JS_VALUE_TYPE) \
403 V(JS_DATE_TYPE) \ 404 V(JS_DATE_TYPE) \
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 V(TYPE_SWITCH_INFO, TypeSwitchInfo, type_switch_info) \ 501 V(TYPE_SWITCH_INFO, TypeSwitchInfo, type_switch_info) \
501 V(SCRIPT, Script, script) \ 502 V(SCRIPT, Script, script) \
502 V(ALLOCATION_SITE, AllocationSite, allocation_site) \ 503 V(ALLOCATION_SITE, AllocationSite, allocation_site) \
503 V(ALLOCATION_MEMENTO, AllocationMemento, allocation_memento) \ 504 V(ALLOCATION_MEMENTO, AllocationMemento, allocation_memento) \
504 V(CODE_CACHE, CodeCache, code_cache) \ 505 V(CODE_CACHE, CodeCache, code_cache) \
505 V(POLYMORPHIC_CODE_CACHE, PolymorphicCodeCache, polymorphic_code_cache) \ 506 V(POLYMORPHIC_CODE_CACHE, PolymorphicCodeCache, polymorphic_code_cache) \
506 V(TYPE_FEEDBACK_INFO, TypeFeedbackInfo, type_feedback_info) \ 507 V(TYPE_FEEDBACK_INFO, TypeFeedbackInfo, type_feedback_info) \
507 V(ALIASED_ARGUMENTS_ENTRY, AliasedArgumentsEntry, aliased_arguments_entry) \ 508 V(ALIASED_ARGUMENTS_ENTRY, AliasedArgumentsEntry, aliased_arguments_entry) \
508 V(DEBUG_INFO, DebugInfo, debug_info) \ 509 V(DEBUG_INFO, DebugInfo, debug_info) \
509 V(BREAK_POINT_INFO, BreakPointInfo, break_point_info) \ 510 V(BREAK_POINT_INFO, BreakPointInfo, break_point_info) \
510 V(PROTOTYPE_INFO, PrototypeInfo, prototype_info) 511 V(PROTOTYPE_INFO, PrototypeInfo, prototype_info) \
512 V(SLOPPY_BLOCK_WITH_EVAL_CONTEXT_EXTENSION, \
513 SloppyBlockWithEvalContextExtension, \
514 sloppy_block_with_eval_context_extension)
511 515
512 // We use the full 8 bits of the instance_type field to encode heap object 516 // We use the full 8 bits of the instance_type field to encode heap object
513 // instance types. The high-order bit (bit 7) is set if the object is not a 517 // instance types. The high-order bit (bit 7) is set if the object is not a
514 // string, and cleared if it is a string. 518 // string, and cleared if it is a string.
515 const uint32_t kIsNotStringMask = 0x80; 519 const uint32_t kIsNotStringMask = 0x80;
516 const uint32_t kStringTag = 0x0; 520 const uint32_t kStringTag = 0x0;
517 const uint32_t kNotStringTag = 0x80; 521 const uint32_t kNotStringTag = 0x80;
518 522
519 // Bit 6 indicates that the object is an internalized string (if set) or not. 523 // Bit 6 indicates that the object is an internalized string (if set) or not.
520 // Bit 7 has to be clear as well. 524 // Bit 7 has to be clear as well.
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 ALIASED_ARGUMENTS_ENTRY_TYPE, 682 ALIASED_ARGUMENTS_ENTRY_TYPE,
679 BOX_TYPE, 683 BOX_TYPE,
680 DEBUG_INFO_TYPE, 684 DEBUG_INFO_TYPE,
681 BREAK_POINT_INFO_TYPE, 685 BREAK_POINT_INFO_TYPE,
682 FIXED_ARRAY_TYPE, 686 FIXED_ARRAY_TYPE,
683 SHARED_FUNCTION_INFO_TYPE, 687 SHARED_FUNCTION_INFO_TYPE,
684 CELL_TYPE, 688 CELL_TYPE,
685 WEAK_CELL_TYPE, 689 WEAK_CELL_TYPE,
686 PROPERTY_CELL_TYPE, 690 PROPERTY_CELL_TYPE,
687 PROTOTYPE_INFO_TYPE, 691 PROTOTYPE_INFO_TYPE,
692 SLOPPY_BLOCK_WITH_EVAL_CONTEXT_EXTENSION_TYPE,
688 693
689 // All the following types are subtypes of JSReceiver, which corresponds to 694 // All the following types are subtypes of JSReceiver, which corresponds to
690 // objects in the JS sense. The first and the last type in this range are 695 // objects in the JS sense. The first and the last type in this range are
691 // the two forms of function. This organization enables using the same 696 // the two forms of function. This organization enables using the same
692 // compares for checking the JS_RECEIVER/SPEC_OBJECT range and the 697 // compares for checking the JS_RECEIVER/SPEC_OBJECT range and the
693 // NONCALLABLE_JS_OBJECT range. 698 // NONCALLABLE_JS_OBJECT range.
694 JS_FUNCTION_PROXY_TYPE, // FIRST_JS_RECEIVER_TYPE, FIRST_JS_PROXY_TYPE 699 JS_FUNCTION_PROXY_TYPE, // FIRST_JS_RECEIVER_TYPE, FIRST_JS_PROXY_TYPE
695 JS_PROXY_TYPE, // LAST_JS_PROXY_TYPE 700 JS_PROXY_TYPE, // LAST_JS_PROXY_TYPE
696 JS_VALUE_TYPE, // FIRST_JS_OBJECT_TYPE 701 JS_VALUE_TYPE, // FIRST_JS_OBJECT_TYPE
697 JS_MESSAGE_OBJECT_TYPE, 702 JS_MESSAGE_OBJECT_TYPE,
(...skipping 3043 matching lines...) Expand 10 before | Expand all | Expand 10 after
3741 3746
3742 // Return the type of this scope. 3747 // Return the type of this scope.
3743 ScopeType scope_type(); 3748 ScopeType scope_type();
3744 3749
3745 // Does this scope call eval? 3750 // Does this scope call eval?
3746 bool CallsEval(); 3751 bool CallsEval();
3747 3752
3748 // Return the language mode of this scope. 3753 // Return the language mode of this scope.
3749 LanguageMode language_mode(); 3754 LanguageMode language_mode();
3750 3755
3756 // True if this scope is a (var) declaration scope.
3757 bool is_declaration_scope();
3758
3751 // Does this scope make a sloppy eval call? 3759 // Does this scope make a sloppy eval call?
3752 bool CallsSloppyEval() { return CallsEval() && is_sloppy(language_mode()); } 3760 bool CallsSloppyEval() { return CallsEval() && is_sloppy(language_mode()); }
3753 3761
3754 // Return the total number of locals allocated on the stack and in the 3762 // Return the total number of locals allocated on the stack and in the
3755 // context. This includes the parameters that are allocated in the context. 3763 // context. This includes the parameters that are allocated in the context.
3756 int LocalCount(); 3764 int LocalCount();
3757 3765
3758 // Return the number of stack slots for code. This number consists of two 3766 // Return the number of stack slots for code. This number consists of two
3759 // parts: 3767 // parts:
3760 // 1. One stack slot per stack allocated local. 3768 // 1. One stack slot per stack allocated local.
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
3964 // Used for the function name variable for named function expressions, and for 3972 // Used for the function name variable for named function expressions, and for
3965 // the receiver. 3973 // the receiver.
3966 enum VariableAllocationInfo { NONE, STACK, CONTEXT, UNUSED }; 3974 enum VariableAllocationInfo { NONE, STACK, CONTEXT, UNUSED };
3967 3975
3968 // Properties of scopes. 3976 // Properties of scopes.
3969 class ScopeTypeField : public BitField<ScopeType, 0, 4> {}; 3977 class ScopeTypeField : public BitField<ScopeType, 0, 4> {};
3970 class CallsEvalField : public BitField<bool, ScopeTypeField::kNext, 1> {}; 3978 class CallsEvalField : public BitField<bool, ScopeTypeField::kNext, 1> {};
3971 STATIC_ASSERT(LANGUAGE_END == 3); 3979 STATIC_ASSERT(LANGUAGE_END == 3);
3972 class LanguageModeField 3980 class LanguageModeField
3973 : public BitField<LanguageMode, CallsEvalField::kNext, 2> {}; 3981 : public BitField<LanguageMode, CallsEvalField::kNext, 2> {};
3982 class DeclarationScopeField
3983 : public BitField<bool, LanguageModeField::kNext, 1> {};
3974 class ReceiverVariableField 3984 class ReceiverVariableField
3975 : public BitField<VariableAllocationInfo, LanguageModeField::kNext, 2> {}; 3985 : public BitField<VariableAllocationInfo, DeclarationScopeField::kNext,
3986 2> {};
3976 class FunctionVariableField 3987 class FunctionVariableField
3977 : public BitField<VariableAllocationInfo, ReceiverVariableField::kNext, 3988 : public BitField<VariableAllocationInfo, ReceiverVariableField::kNext,
3978 2> {}; 3989 2> {};
3979 class FunctionVariableMode 3990 class FunctionVariableMode
3980 : public BitField<VariableMode, FunctionVariableField::kNext, 3> {}; 3991 : public BitField<VariableMode, FunctionVariableField::kNext, 3> {};
3981 class AsmModuleField : public BitField<bool, FunctionVariableMode::kNext, 1> { 3992 class AsmModuleField : public BitField<bool, FunctionVariableMode::kNext, 1> {
3982 }; 3993 };
3983 class AsmFunctionField : public BitField<bool, AsmModuleField::kNext, 1> {}; 3994 class AsmFunctionField : public BitField<bool, AsmModuleField::kNext, 1> {};
3984 class HasSimpleParametersField 3995 class HasSimpleParametersField
3985 : public BitField<bool, AsmFunctionField::kNext, 1> {}; 3996 : public BitField<bool, AsmFunctionField::kNext, 1> {};
(...skipping 1842 matching lines...) Expand 10 before | Expand all | Expand 10 after
5828 static const int kRegistrySlotOffset = kPrototypeUsersOffset + kPointerSize; 5839 static const int kRegistrySlotOffset = kPrototypeUsersOffset + kPointerSize;
5829 static const int kValidityCellOffset = kRegistrySlotOffset + kPointerSize; 5840 static const int kValidityCellOffset = kRegistrySlotOffset + kPointerSize;
5830 static const int kConstructorNameOffset = kValidityCellOffset + kPointerSize; 5841 static const int kConstructorNameOffset = kValidityCellOffset + kPointerSize;
5831 static const int kSize = kConstructorNameOffset + kPointerSize; 5842 static const int kSize = kConstructorNameOffset + kPointerSize;
5832 5843
5833 private: 5844 private:
5834 DISALLOW_IMPLICIT_CONSTRUCTORS(PrototypeInfo); 5845 DISALLOW_IMPLICIT_CONSTRUCTORS(PrototypeInfo);
5835 }; 5846 };
5836 5847
5837 5848
5849 // Pair used to store both a ScopeInfo and an extension object in the extension
5850 // slot of a block context. Needed in the rare case where a declaration block
5851 // scope (a "varblock" as used to desugar parameter destructuring) also contains
5852 // a sloppy direct eval. (In no other case both are needed at the same time.)
5853 class SloppyBlockWithEvalContextExtension : public Struct {
5854 public:
5855 // [scope_info]: Scope info.
5856 DECL_ACCESSORS(scope_info, ScopeInfo)
5857 // [extension]: Extension object.
5858 DECL_ACCESSORS(extension, JSObject)
5859
5860 DECLARE_CAST(SloppyBlockWithEvalContextExtension)
5861
5862 // Dispatched behavior.
5863 DECLARE_PRINTER(SloppyBlockWithEvalContextExtension)
5864 DECLARE_VERIFIER(SloppyBlockWithEvalContextExtension)
5865
5866 static const int kScopeInfoOffset = HeapObject::kHeaderSize;
5867 static const int kExtensionOffset = kScopeInfoOffset + kPointerSize;
5868 static const int kSize = kExtensionOffset + kPointerSize;
5869
5870 private:
5871 DISALLOW_IMPLICIT_CONSTRUCTORS(SloppyBlockWithEvalContextExtension);
5872 };
5873
5874
5838 // Script describes a script which has been added to the VM. 5875 // Script describes a script which has been added to the VM.
5839 class Script: public Struct { 5876 class Script: public Struct {
5840 public: 5877 public:
5841 // Script types. 5878 // Script types.
5842 enum Type { 5879 enum Type {
5843 TYPE_NATIVE = 0, 5880 TYPE_NATIVE = 0,
5844 TYPE_EXTENSION = 1, 5881 TYPE_EXTENSION = 1,
5845 TYPE_NORMAL = 2 5882 TYPE_NORMAL = 2
5846 }; 5883 };
5847 5884
(...skipping 4410 matching lines...) Expand 10 before | Expand all | Expand 10 after
10258 } else { 10295 } else {
10259 value &= ~(1 << bit_position); 10296 value &= ~(1 << bit_position);
10260 } 10297 }
10261 return value; 10298 return value;
10262 } 10299 }
10263 }; 10300 };
10264 10301
10265 } } // namespace v8::internal 10302 } } // namespace v8::internal
10266 10303
10267 #endif // V8_OBJECTS_H_ 10304 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/hydrogen.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698