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

Side by Side Diff: src/objects.h

Issue 1140633003: Reapply "Resolve references to "this" the same way as normal variables"" (Closed) Base URL: https://chromium.googlesource.com/v8/v8@master
Patch Set: ScopeInfo records slot of "this" binding; formatting Created 5 years, 7 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/mips64/lithium-codegen-mips64.cc ('k') | src/parser.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 4251 matching lines...) Expand 10 before | Expand all | Expand 10 after
4262 4262
4263 // Return the number of context slots for code if a context is allocated. This 4263 // Return the number of context slots for code if a context is allocated. This
4264 // number consists of three parts: 4264 // number consists of three parts:
4265 // 1. Size of fixed header for every context: Context::MIN_CONTEXT_SLOTS 4265 // 1. Size of fixed header for every context: Context::MIN_CONTEXT_SLOTS
4266 // 2. One context slot per context allocated local. 4266 // 2. One context slot per context allocated local.
4267 // 3. One context slot for the function name if it is context allocated. 4267 // 3. One context slot for the function name if it is context allocated.
4268 // Parameters allocated in the context count as context allocated locals. If 4268 // Parameters allocated in the context count as context allocated locals. If
4269 // no contexts are allocated for this scope ContextLength returns 0. 4269 // no contexts are allocated for this scope ContextLength returns 0.
4270 int ContextLength(); 4270 int ContextLength();
4271 4271
4272 // Does this scope declare a "this" binding?
4273 bool HasReceiver();
4274
4275 // Does this scope declare a "this" binding, and the "this" binding is stack-
4276 // or context-allocated?
4277 bool HasAllocatedReceiver();
4278
4272 // Is this scope the scope of a named function expression? 4279 // Is this scope the scope of a named function expression?
4273 bool HasFunctionName(); 4280 bool HasFunctionName();
4274 4281
4275 // Return if this has context allocated locals. 4282 // Return if this has context allocated locals.
4276 bool HasHeapAllocatedLocals(); 4283 bool HasHeapAllocatedLocals();
4277 4284
4278 // Return if contexts are allocated for this scope. 4285 // Return if contexts are allocated for this scope.
4279 bool HasContext(); 4286 bool HasContext();
4280 4287
4281 // Return if this is a function scope with "use asm". 4288 // Return if this is a function scope with "use asm".
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
4342 // parameter index for a given parameter name if the parameter is present; 4349 // parameter index for a given parameter name if the parameter is present;
4343 // otherwise returns a value < 0. The name must be an internalized string. 4350 // otherwise returns a value < 0. The name must be an internalized string.
4344 int ParameterIndex(String* name); 4351 int ParameterIndex(String* name);
4345 4352
4346 // Lookup support for serialized scope info. Returns the function context 4353 // Lookup support for serialized scope info. Returns the function context
4347 // slot index if the function name is present and context-allocated (named 4354 // slot index if the function name is present and context-allocated (named
4348 // function expressions, only), otherwise returns a value < 0. The name 4355 // function expressions, only), otherwise returns a value < 0. The name
4349 // must be an internalized string. 4356 // must be an internalized string.
4350 int FunctionContextSlotIndex(String* name, VariableMode* mode); 4357 int FunctionContextSlotIndex(String* name, VariableMode* mode);
4351 4358
4359 // Lookup support for serialized scope info. Returns the receiver context
4360 // slot index if scope has a "this" binding, and the binding is
4361 // context-allocated. Otherwise returns a value < 0.
4362 int ReceiverContextSlotIndex();
4363
4352 bool block_scope_is_class_scope(); 4364 bool block_scope_is_class_scope();
4353 FunctionKind function_kind(); 4365 FunctionKind function_kind();
4354 4366
4355 // Copies all the context locals into an object used to materialize a scope. 4367 // Copies all the context locals into an object used to materialize a scope.
4356 static bool CopyContextLocalsToScopeObject(Handle<ScopeInfo> scope_info, 4368 static bool CopyContextLocalsToScopeObject(Handle<ScopeInfo> scope_info,
4357 Handle<Context> context, 4369 Handle<Context> context,
4358 Handle<JSObject> scope_object); 4370 Handle<JSObject> scope_object);
4359 4371
4360 4372
4361 static Handle<ScopeInfo> Create(Isolate* isolate, Zone* zone, Scope* scope); 4373 static Handle<ScopeInfo> Create(Isolate* isolate, Zone* zone, Scope* scope);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
4429 // 5. ContextLocalInfoEntries: 4441 // 5. ContextLocalInfoEntries:
4430 // Contains the variable modes and initialization flags corresponding to 4442 // Contains the variable modes and initialization flags corresponding to
4431 // the context locals in ContextLocalNameEntries. One slot is used per 4443 // the context locals in ContextLocalNameEntries. One slot is used per
4432 // context local, so in total this part occupies ContextLocalCount() 4444 // context local, so in total this part occupies ContextLocalCount()
4433 // slots in the array. 4445 // slots in the array.
4434 // 6. StrongModeFreeVariableNameEntries: 4446 // 6. StrongModeFreeVariableNameEntries:
4435 // Stores the names of strong mode free variables. 4447 // Stores the names of strong mode free variables.
4436 // 7. StrongModeFreeVariablePositionEntries: 4448 // 7. StrongModeFreeVariablePositionEntries:
4437 // Stores the locations (start and end position) of strong mode free 4449 // Stores the locations (start and end position) of strong mode free
4438 // variables. 4450 // variables.
4439 // 8. FunctionNameEntryIndex: 4451 // 8. RecieverEntryIndex:
4452 // If the scope binds a "this" value, one slot is reserved to hold the
4453 // context or stack slot index for the variable.
4454 // 9. FunctionNameEntryIndex:
4440 // If the scope belongs to a named function expression this part contains 4455 // If the scope belongs to a named function expression this part contains
4441 // information about the function variable. It always occupies two array 4456 // information about the function variable. It always occupies two array
4442 // slots: a. The name of the function variable. 4457 // slots: a. The name of the function variable.
4443 // b. The context or stack slot index for the variable. 4458 // b. The context or stack slot index for the variable.
4444 int ParameterEntriesIndex(); 4459 int ParameterEntriesIndex();
4445 int StackLocalFirstSlotIndex(); 4460 int StackLocalFirstSlotIndex();
4446 int StackLocalEntriesIndex(); 4461 int StackLocalEntriesIndex();
4447 int ContextLocalNameEntriesIndex(); 4462 int ContextLocalNameEntriesIndex();
4448 int ContextLocalInfoEntriesIndex(); 4463 int ContextLocalInfoEntriesIndex();
4449 int StrongModeFreeVariableNameEntriesIndex(); 4464 int StrongModeFreeVariableNameEntriesIndex();
4450 int StrongModeFreeVariablePositionEntriesIndex(); 4465 int StrongModeFreeVariablePositionEntriesIndex();
4466 int ReceiverEntryIndex();
4451 int FunctionNameEntryIndex(); 4467 int FunctionNameEntryIndex();
4452 4468
4453 // Location of the function variable for named function expressions. 4469 // Used for the function name variable for named function expressions, and for
4454 enum FunctionVariableInfo { 4470 // the receiver.
4455 NONE, // No function name present. 4471 enum VariableAllocationInfo { NONE, STACK, CONTEXT, UNUSED };
4456 STACK, // Function
4457 CONTEXT,
4458 UNUSED
4459 };
4460 4472
4461 // Properties of scopes. 4473 // Properties of scopes.
4462 class ScopeTypeField : public BitField<ScopeType, 0, 4> {}; 4474 class ScopeTypeField : public BitField<ScopeType, 0, 4> {};
4463 class CallsEvalField : public BitField<bool, 4, 1> {}; 4475 class CallsEvalField : public BitField<bool, ScopeTypeField::kNext, 1> {};
4464 STATIC_ASSERT(LANGUAGE_END == 3); 4476 STATIC_ASSERT(LANGUAGE_END == 3);
4465 class LanguageModeField : public BitField<LanguageMode, 5, 2> {}; 4477 class LanguageModeField
4466 class FunctionVariableField : public BitField<FunctionVariableInfo, 7, 2> {}; 4478 : public BitField<LanguageMode, CallsEvalField::kNext, 2> {};
4467 class FunctionVariableMode : public BitField<VariableMode, 9, 3> {}; 4479 class ReceiverVariableField
4468 class AsmModuleField : public BitField<bool, 12, 1> {}; 4480 : public BitField<VariableAllocationInfo, LanguageModeField::kNext, 2> {};
4469 class AsmFunctionField : public BitField<bool, 13, 1> {}; 4481 class FunctionVariableField
4482 : public BitField<VariableAllocationInfo, ReceiverVariableField::kNext,
4483 2> {};
4484 class FunctionVariableMode
4485 : public BitField<VariableMode, FunctionVariableField::kNext, 3> {};
4486 class AsmModuleField : public BitField<bool, FunctionVariableMode::kNext, 1> {
4487 };
4488 class AsmFunctionField : public BitField<bool, AsmModuleField::kNext, 1> {};
4470 class IsSimpleParameterListField 4489 class IsSimpleParameterListField
4471 : public BitField<bool, AsmFunctionField::kNext, 1> {}; 4490 : public BitField<bool, AsmFunctionField::kNext, 1> {};
4472 class BlockScopeIsClassScopeField 4491 class BlockScopeIsClassScopeField
4473 : public BitField<bool, IsSimpleParameterListField::kNext, 1> {}; 4492 : public BitField<bool, IsSimpleParameterListField::kNext, 1> {};
4474 class FunctionKindField 4493 class FunctionKindField
4475 : public BitField<FunctionKind, BlockScopeIsClassScopeField::kNext, 8> {}; 4494 : public BitField<FunctionKind, BlockScopeIsClassScopeField::kNext, 8> {};
4476 4495
4477 // BitFields representing the encoded information for context locals in the 4496 // BitFields representing the encoded information for context locals in the
4478 // ContextLocalInfoEntries part. 4497 // ContextLocalInfoEntries part.
4479 class ContextLocalMode: public BitField<VariableMode, 0, 3> {}; 4498 class ContextLocalMode: public BitField<VariableMode, 0, 3> {};
(...skipping 6632 matching lines...) Expand 10 before | Expand all | Expand 10 after
11112 } else { 11131 } else {
11113 value &= ~(1 << bit_position); 11132 value &= ~(1 << bit_position);
11114 } 11133 }
11115 return value; 11134 return value;
11116 } 11135 }
11117 }; 11136 };
11118 11137
11119 } } // namespace v8::internal 11138 } } // namespace v8::internal
11120 11139
11121 #endif // V8_OBJECTS_H_ 11140 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/mips64/lithium-codegen-mips64.cc ('k') | src/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698