blob: a295f8b0aa4ff0e3547ac77ab6921f5ed5194abc [file] [log] [blame]
yangguo@chromium.org659ceec2012-01-26 07:37:54 +00001// Copyright 2012 the V8 project authors. All rights reserved.
erik.corry@gmail.com4a6c3272010-11-18 12:04:40 +00002// Redistribution and use in source and binary forms, with or without
3// modification, are permitted provided that the following conditions are
4// met:
5//
6// * Redistributions of source code must retain the above copyright
7// notice, this list of conditions and the following disclaimer.
8// * Redistributions in binary form must reproduce the above
9// copyright notice, this list of conditions and the following
10// disclaimer in the documentation and/or other materials provided
11// with the distribution.
12// * Neither the name of Google Inc. nor the names of its
13// contributors may be used to endorse or promote products derived
14// from this software without specific prior written permission.
15//
16// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28#ifndef V8_V8GLOBALS_H_
29#define V8_V8GLOBALS_H_
30
31#include "globals.h"
danno@chromium.orgc612e022011-11-10 11:38:15 +000032#include "checks.h"
erik.corry@gmail.com4a6c3272010-11-18 12:04:40 +000033
34namespace v8 {
35namespace internal {
36
37// This file contains constants and global declarations related to the
38// V8 system.
39
40// Mask for the sign bit in a smi.
41const intptr_t kSmiSignMask = kIntptrSignBit;
42
43const int kObjectAlignmentBits = kPointerSizeLog2;
44const intptr_t kObjectAlignment = 1 << kObjectAlignmentBits;
45const intptr_t kObjectAlignmentMask = kObjectAlignment - 1;
46
47// Desired alignment for pointers.
48const intptr_t kPointerAlignment = (1 << kPointerSizeLog2);
49const intptr_t kPointerAlignmentMask = kPointerAlignment - 1;
50
erik.corry@gmail.comed49e962012-04-17 11:57:53 +000051// Desired alignment for double values.
52const intptr_t kDoubleAlignment = 8;
53const intptr_t kDoubleAlignmentMask = kDoubleAlignment - 1;
54
erik.corry@gmail.com4a6c3272010-11-18 12:04:40 +000055// Desired alignment for maps.
56#if V8_HOST_ARCH_64_BIT
57const intptr_t kMapAlignmentBits = kObjectAlignmentBits;
58#else
59const intptr_t kMapAlignmentBits = kObjectAlignmentBits + 3;
60#endif
61const intptr_t kMapAlignment = (1 << kMapAlignmentBits);
62const intptr_t kMapAlignmentMask = kMapAlignment - 1;
63
64// Desired alignment for generated code is 32 bytes (to improve cache line
65// utilization).
66const int kCodeAlignmentBits = 5;
67const intptr_t kCodeAlignment = 1 << kCodeAlignmentBits;
68const intptr_t kCodeAlignmentMask = kCodeAlignment - 1;
69
70// Tag information for Failure.
71const int kFailureTag = 3;
72const int kFailureTagSize = 2;
73const intptr_t kFailureTagMask = (1 << kFailureTagSize) - 1;
74
75
76// Zap-value: The value used for zapping dead objects.
erik.corry@gmail.comd91075f2011-02-10 07:45:38 +000077// Should be a recognizable hex value tagged as a failure.
erik.corry@gmail.com4a6c3272010-11-18 12:04:40 +000078#ifdef V8_HOST_ARCH_64_BIT
79const Address kZapValue =
erik.corry@gmail.comd91075f2011-02-10 07:45:38 +000080 reinterpret_cast<Address>(V8_UINT64_C(0xdeadbeedbeadbeef));
erik.corry@gmail.com4a6c3272010-11-18 12:04:40 +000081const Address kHandleZapValue =
erik.corry@gmail.comd91075f2011-02-10 07:45:38 +000082 reinterpret_cast<Address>(V8_UINT64_C(0x1baddead0baddeaf));
erik.corry@gmail.com4a6c3272010-11-18 12:04:40 +000083const Address kFromSpaceZapValue =
erik.corry@gmail.comd91075f2011-02-10 07:45:38 +000084 reinterpret_cast<Address>(V8_UINT64_C(0x1beefdad0beefdaf));
sgjesse@chromium.orgc6c57182011-01-17 12:24:25 +000085const uint64_t kDebugZapValue = V8_UINT64_C(0xbadbaddbbadbaddb);
erik.corry@gmail.comd91075f2011-02-10 07:45:38 +000086const uint64_t kSlotsZapValue = V8_UINT64_C(0xbeefdeadbeefdeef);
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +000087const uint64_t kFreeListZapValue = 0xfeed1eaffeed1eaf;
erik.corry@gmail.com4a6c3272010-11-18 12:04:40 +000088#else
erik.corry@gmail.comd91075f2011-02-10 07:45:38 +000089const Address kZapValue = reinterpret_cast<Address>(0xdeadbeef);
90const Address kHandleZapValue = reinterpret_cast<Address>(0xbaddeaf);
91const Address kFromSpaceZapValue = reinterpret_cast<Address>(0xbeefdaf);
92const uint32_t kSlotsZapValue = 0xbeefdeef;
erik.corry@gmail.com4a6c3272010-11-18 12:04:40 +000093const uint32_t kDebugZapValue = 0xbadbaddb;
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +000094const uint32_t kFreeListZapValue = 0xfeed1eaf;
erik.corry@gmail.com4a6c3272010-11-18 12:04:40 +000095#endif
96
97
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +000098// Number of bits to represent the page size for paged spaces. The value of 20
99// gives 1Mb bytes per page.
100const int kPageSizeBits = 20;
erik.corry@gmail.com4a6c3272010-11-18 12:04:40 +0000101
102// On Intel architecture, cache line size is 64 bytes.
103// On ARM it may be less (32 bytes), but as far this constant is
104// used for aligning data, it doesn't hurt to align on a greater value.
105const int kProcessorCacheLineSize = 64;
106
107// Constants relevant to double precision floating point numbers.
erik.corry@gmail.com4a6c3272010-11-18 12:04:40 +0000108// If looking only at the top 32 bits, the QNaN mask is bits 19 to 30.
109const uint32_t kQuietNaNHighBitsMask = 0xfff << (51 - 32);
110
111
112// -----------------------------------------------------------------------------
113// Forward declarations for frequently used classes
erik.corry@gmail.com4a6c3272010-11-18 12:04:40 +0000114
115class AccessorInfo;
116class Allocation;
117class Arguments;
118class Assembler;
119class AssertNoAllocation;
erik.corry@gmail.com4a6c3272010-11-18 12:04:40 +0000120class Code;
121class CodeGenerator;
122class CodeStub;
123class Context;
124class Debug;
125class Debugger;
126class DebugInfo;
127class Descriptor;
128class DescriptorArray;
yangguo@chromium.org99aa4902012-07-06 16:21:55 +0000129class TransitionArray;
erik.corry@gmail.com4a6c3272010-11-18 12:04:40 +0000130class ExternalReference;
131class FixedArray;
erik.corry@gmail.com4a6c3272010-11-18 12:04:40 +0000132class FunctionTemplateInfo;
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000133class MemoryChunk;
erik.corry@gmail.comf2038fb2012-01-16 11:42:08 +0000134class SeededNumberDictionary;
135class UnseededNumberDictionary;
erik.corry@gmail.com4a6c3272010-11-18 12:04:40 +0000136class StringDictionary;
137template <typename T> class Handle;
138class Heap;
139class HeapObject;
140class IC;
141class InterceptorInfo;
erik.corry@gmail.com4a6c3272010-11-18 12:04:40 +0000142class JSArray;
143class JSFunction;
144class JSObject;
145class LargeObjectSpace;
146class LookupResult;
147class MacroAssembler;
148class Map;
149class MapSpace;
150class MarkCompactCollector;
151class NewSpace;
erik.corry@gmail.com4a6c3272010-11-18 12:04:40 +0000152class Object;
153class MaybeObject;
154class OldSpace;
ager@chromium.orgea91cc52011-05-23 06:06:11 +0000155class Foreign;
erik.corry@gmail.com4a6c3272010-11-18 12:04:40 +0000156class Scope;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000157class ScopeInfo;
erik.corry@gmail.com4a6c3272010-11-18 12:04:40 +0000158class Script;
erik.corry@gmail.com4a6c3272010-11-18 12:04:40 +0000159class Smi;
160template <typename Config, class Allocator = FreeStoreAllocationPolicy>
161 class SplayTree;
erik.corry@gmail.com4a6c3272010-11-18 12:04:40 +0000162class String;
163class Struct;
erik.corry@gmail.com4a6c3272010-11-18 12:04:40 +0000164class Variable;
erik.corry@gmail.com4a6c3272010-11-18 12:04:40 +0000165class RelocInfo;
166class Deserializer;
167class MessageLocation;
168class ObjectGroup;
169class TickSample;
170class VirtualMemory;
171class Mutex;
172
173typedef bool (*WeakSlotCallback)(Object** pointer);
174
kmillikin@chromium.orgc53e10d2011-05-18 09:12:58 +0000175typedef bool (*WeakSlotCallbackWithHeap)(Heap* heap, Object** pointer);
176
erik.corry@gmail.com4a6c3272010-11-18 12:04:40 +0000177// -----------------------------------------------------------------------------
178// Miscellaneous
179
180// NOTE: SpaceIterator depends on AllocationSpace enumeration values being
181// consecutive.
182enum AllocationSpace {
183 NEW_SPACE, // Semispaces collected with copying collector.
184 OLD_POINTER_SPACE, // May contain pointers to new space.
185 OLD_DATA_SPACE, // Must not have pointers to new space.
186 CODE_SPACE, // No pointers to new space, marked executable.
187 MAP_SPACE, // Only and all map objects.
188 CELL_SPACE, // Only and all cell objects.
189 LO_SPACE, // Promoted large objects.
190
191 FIRST_SPACE = NEW_SPACE,
192 LAST_SPACE = LO_SPACE,
193 FIRST_PAGED_SPACE = OLD_POINTER_SPACE,
194 LAST_PAGED_SPACE = CELL_SPACE
195};
196const int kSpaceTagSize = 3;
197const int kSpaceTagMask = (1 << kSpaceTagSize) - 1;
198
199
200// A flag that indicates whether objects should be pretenured when
201// allocated (allocated directly into the old generation) or not
202// (allocated in the young generation if the object size and type
203// allows).
204enum PretenureFlag { NOT_TENURED, TENURED };
205
206enum GarbageCollector { SCAVENGER, MARK_COMPACTOR };
207
208enum Executability { NOT_EXECUTABLE, EXECUTABLE };
209
kmillikin@chromium.orgc53e10d2011-05-18 09:12:58 +0000210enum VisitMode {
211 VISIT_ALL,
212 VISIT_ALL_IN_SCAVENGE,
213 VISIT_ALL_IN_SWEEP_NEWSPACE,
214 VISIT_ONLY_STRONG
215};
erik.corry@gmail.com4a6c3272010-11-18 12:04:40 +0000216
217// Flag indicating whether code is built into the VM (one of the natives files).
218enum NativesFlag { NOT_NATIVES_CODE, NATIVES_CODE };
219
220
221// A CodeDesc describes a buffer holding instructions and relocation
222// information. The instructions start at the beginning of the buffer
223// and grow forward, the relocation information starts at the end of
224// the buffer and grows backward.
225//
226// |<--------------- buffer_size ---------------->|
227// |<-- instr_size -->| |<-- reloc_size -->|
228// +==================+========+==================+
229// | instructions | free | reloc info |
230// +==================+========+==================+
231// ^
232// |
233// buffer
234
235struct CodeDesc {
236 byte* buffer;
237 int buffer_size;
238 int instr_size;
239 int reloc_size;
240 Assembler* origin;
241};
242
243
erik.corry@gmail.com4a6c3272010-11-18 12:04:40 +0000244// Callback function used for iterating objects in heap spaces,
245// for example, scanning heap objects.
246typedef int (*HeapObjectCallback)(HeapObject* obj);
247
248
249// Callback function used for checking constraints when copying/relocating
250// objects. Returns true if an object can be copied/relocated from its
251// old_addr to a new_addr.
252typedef bool (*ConstraintCallback)(Address new_addr, Address old_addr);
253
254
255// Callback function on inline caches, used for iterating over inline caches
256// in compiled code.
257typedef void (*InlineCacheCallback)(Code* code, Address ic);
258
259
260// State for inline cache call sites. Aliased as IC::State.
261enum InlineCacheState {
262 // Has never been executed.
263 UNINITIALIZED,
264 // Has been executed but monomorhic state has been delayed.
265 PREMONOMORPHIC,
266 // Has been executed and only one receiver type has been seen.
267 MONOMORPHIC,
268 // Like MONOMORPHIC but check failed due to prototype.
269 MONOMORPHIC_PROTOTYPE_FAILURE,
270 // Multiple receiver types have been seen.
271 MEGAMORPHIC,
272 // Special states for debug break or step in prepare stubs.
273 DEBUG_BREAK,
274 DEBUG_PREPARE_STEP_IN
275};
276
277
kasperl@chromium.orga5551262010-12-07 12:49:48 +0000278enum CheckType {
279 RECEIVER_MAP_CHECK,
280 STRING_CHECK,
281 NUMBER_CHECK,
282 BOOLEAN_CHECK
283};
284
285
erik.corry@gmail.com4a6c3272010-11-18 12:04:40 +0000286enum CallFunctionFlags {
287 NO_CALL_FUNCTION_FLAGS = 0,
danno@chromium.org40cb8782011-05-25 07:58:50 +0000288 // Receiver might implicitly be the global objects. If it is, the
289 // hole is passed to the call function stub.
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000290 RECEIVER_MIGHT_BE_IMPLICIT = 1 << 0,
291 // The call target is cached in the instruction stream.
292 RECORD_CALL_TARGET = 1 << 1
erik.corry@gmail.com4a6c3272010-11-18 12:04:40 +0000293};
294
295
296enum InlineCacheHolderFlag {
297 OWN_MAP, // For fast properties objects.
298 PROTOTYPE_MAP // For slow properties objects (except GlobalObjects).
299};
300
301
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000302// The Store Buffer (GC).
303typedef enum {
304 kStoreBufferFullEvent,
305 kStoreBufferStartScanningPagesEvent,
306 kStoreBufferScanningPageEvent
307} StoreBufferEvent;
308
309
310typedef void (*StoreBufferCallback)(Heap* heap,
311 MemoryChunk* page,
312 StoreBufferEvent event);
313
314
erik.corry@gmail.com4a6c3272010-11-18 12:04:40 +0000315// Union used for fast testing of specific double values.
316union DoubleRepresentation {
317 double value;
318 int64_t bits;
319 DoubleRepresentation(double x) { value = x; }
320};
321
322
323// Union used for customized checking of the IEEE double types
324// inlined within v8 runtime, rather than going to the underlying
325// platform headers and libraries
326union IeeeDoubleLittleEndianArchType {
327 double d;
328 struct {
329 unsigned int man_low :32;
330 unsigned int man_high :20;
331 unsigned int exp :11;
332 unsigned int sign :1;
333 } bits;
334};
335
336
337union IeeeDoubleBigEndianArchType {
338 double d;
339 struct {
340 unsigned int sign :1;
341 unsigned int exp :11;
342 unsigned int man_high :20;
343 unsigned int man_low :32;
344 } bits;
345};
346
347
348// AccessorCallback
349struct AccessorDescriptor {
350 MaybeObject* (*getter)(Object* object, void* data);
351 MaybeObject* (*setter)(JSObject* object, Object* value, void* data);
352 void* data;
353};
354
355
whesse@chromium.org030d38e2011-07-13 13:23:34 +0000356// Logging and profiling. A StateTag represents a possible state of
357// the VM. The logger maintains a stack of these. Creating a VMState
358// object enters a state by pushing on the stack, and destroying a
359// VMState object leaves a state by popping the current state from the
360// stack.
erik.corry@gmail.com4a6c3272010-11-18 12:04:40 +0000361
362#define STATE_TAG_LIST(V) \
363 V(JS) \
364 V(GC) \
365 V(COMPILER) \
366 V(OTHER) \
367 V(EXTERNAL)
368
369enum StateTag {
370#define DEF_STATE_TAG(name) name,
371 STATE_TAG_LIST(DEF_STATE_TAG)
372#undef DEF_STATE_TAG
373 // Pseudo-types.
374 state_tag_count
375};
376
377
378// -----------------------------------------------------------------------------
379// Macros
380
381// Testers for test.
382
383#define HAS_SMI_TAG(value) \
384 ((reinterpret_cast<intptr_t>(value) & kSmiTagMask) == kSmiTag)
385
386#define HAS_FAILURE_TAG(value) \
387 ((reinterpret_cast<intptr_t>(value) & kFailureTagMask) == kFailureTag)
388
389// OBJECT_POINTER_ALIGN returns the value aligned as a HeapObject pointer
390#define OBJECT_POINTER_ALIGN(value) \
391 (((value) + kObjectAlignmentMask) & ~kObjectAlignmentMask)
392
393// POINTER_SIZE_ALIGN returns the value aligned as a pointer.
394#define POINTER_SIZE_ALIGN(value) \
395 (((value) + kPointerAlignmentMask) & ~kPointerAlignmentMask)
396
397// MAP_POINTER_ALIGN returns the value aligned as a map pointer.
398#define MAP_POINTER_ALIGN(value) \
399 (((value) + kMapAlignmentMask) & ~kMapAlignmentMask)
400
401// CODE_POINTER_ALIGN returns the value aligned as a generated code segment.
402#define CODE_POINTER_ALIGN(value) \
403 (((value) + kCodeAlignmentMask) & ~kCodeAlignmentMask)
404
405// Support for tracking C++ memory allocation. Insert TRACK_MEMORY("Fisk")
406// inside a C++ class and new and delete will be overloaded so logging is
407// performed.
408// This file (globals.h) is included before log.h, so we use direct calls to
409// the Logger rather than the LOG macro.
410#ifdef DEBUG
411#define TRACK_MEMORY(name) \
412 void* operator new(size_t size) { \
413 void* result = ::operator new(size); \
sgjesse@chromium.orgea88ce92011-03-23 11:19:56 +0000414 Logger::NewEventStatic(name, result, size); \
erik.corry@gmail.com4a6c3272010-11-18 12:04:40 +0000415 return result; \
416 } \
417 void operator delete(void* object) { \
sgjesse@chromium.orgea88ce92011-03-23 11:19:56 +0000418 Logger::DeleteEventStatic(name, object); \
erik.corry@gmail.com4a6c3272010-11-18 12:04:40 +0000419 ::operator delete(object); \
420 }
421#else
422#define TRACK_MEMORY(name)
423#endif
424
425
426// Feature flags bit positions. They are mostly based on the CPUID spec.
427// (We assign CPUID itself to one of the currently reserved bits --
428// feel free to change this if needed.)
429// On X86/X64, values below 32 are bits in EDX, values above 32 are bits in ECX.
430enum CpuFeature { SSE4_1 = 32 + 19, // x86
431 SSE3 = 32 + 0, // x86
432 SSE2 = 26, // x86
433 CMOV = 15, // x86
434 RDTSC = 4, // x86
435 CPUID = 10, // x86
436 VFP3 = 1, // ARM
437 ARMv7 = 2, // ARM
lrn@chromium.org7516f052011-03-30 08:52:27 +0000438 SAHF = 0, // x86
439 FPU = 1}; // MIPS
erik.corry@gmail.com4a6c3272010-11-18 12:04:40 +0000440
kmillikin@chromium.orgc53e10d2011-05-18 09:12:58 +0000441
442// Used to specify if a macro instruction must perform a smi check on tagged
443// values.
444enum SmiCheckType {
rossberg@chromium.orgb4b2aa62011-10-13 09:49:59 +0000445 DONT_DO_SMI_CHECK,
kmillikin@chromium.orgc53e10d2011-05-18 09:12:58 +0000446 DO_SMI_CHECK
447};
448
danno@chromium.org40cb8782011-05-25 07:58:50 +0000449
450// Used to specify whether a receiver is implicitly or explicitly
451// provided to a call.
452enum CallKind {
rossberg@chromium.orgb4b2aa62011-10-13 09:49:59 +0000453 CALL_AS_METHOD,
danno@chromium.org40cb8782011-05-25 07:58:50 +0000454 CALL_AS_FUNCTION
455};
456
svenpanne@chromium.org84bcc552011-07-18 09:50:57 +0000457
erik.corry@gmail.com394dbcf2011-10-27 07:38:48 +0000458enum ScopeType {
459 EVAL_SCOPE, // The top-level scope for an eval source.
460 FUNCTION_SCOPE, // The top-level scope for a function.
jkummerow@chromium.orgf7a58842012-02-21 10:08:21 +0000461 MODULE_SCOPE, // The scope introduced by a module literal
erik.corry@gmail.com394dbcf2011-10-27 07:38:48 +0000462 GLOBAL_SCOPE, // The top-level scope for a program or a top-level eval.
463 CATCH_SCOPE, // The scope introduced by catch.
464 BLOCK_SCOPE, // The scope introduced by a new block.
465 WITH_SCOPE // The scope introduced by with.
466};
467
468
mstarzinger@chromium.org1b3afd12011-11-29 14:28:56 +0000469const uint32_t kHoleNanUpper32 = 0x7FFFFFFF;
470const uint32_t kHoleNanLower32 = 0xFFFFFFFF;
471const uint32_t kNaNOrInfinityLowerBoundUpper32 = 0x7FF00000;
svenpanne@chromium.org84bcc552011-07-18 09:50:57 +0000472
473const uint64_t kHoleNanInt64 =
474 (static_cast<uint64_t>(kHoleNanUpper32) << 32) | kHoleNanLower32;
475const uint64_t kLastNonNaNInt64 =
476 (static_cast<uint64_t>(kNaNOrInfinityLowerBoundUpper32) << 32);
477
rossberg@chromium.orgb4b2aa62011-10-13 09:49:59 +0000478
479enum VariableMode {
480 // User declared variables:
erik.corry@gmail.com394dbcf2011-10-27 07:38:48 +0000481 VAR, // declared via 'var', and 'function' declarations
rossberg@chromium.orgb4b2aa62011-10-13 09:49:59 +0000482
erik.corry@gmail.com394dbcf2011-10-27 07:38:48 +0000483 CONST, // declared via 'const' declarations
rossberg@chromium.orgb4b2aa62011-10-13 09:49:59 +0000484
erik.corry@gmail.com394dbcf2011-10-27 07:38:48 +0000485 CONST_HARMONY, // declared via 'const' declarations in harmony mode
486
487 LET, // declared via 'let' declarations
rossberg@chromium.orgb4b2aa62011-10-13 09:49:59 +0000488
489 // Variables introduced by the compiler:
490 DYNAMIC, // always require dynamic lookup (we don't know
491 // the declaration)
492
493 DYNAMIC_GLOBAL, // requires dynamic lookup, but we know that the
494 // variable is global unless it has been shadowed
495 // by an eval-introduced variable
496
497 DYNAMIC_LOCAL, // requires dynamic lookup, but we know that the
498 // variable is local and where it is unless it
499 // has been shadowed by an eval-introduced
500 // variable
501
502 INTERNAL, // like VAR, but not user-visible (may or may not
503 // be in a context)
504
505 TEMPORARY // temporary variables (not user-visible), never
506 // in a context
507};
508
erik.corry@gmail.com394dbcf2011-10-27 07:38:48 +0000509
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000510// ES6 Draft Rev3 10.2 specifies declarative environment records with mutable
511// and immutable bindings that can be in two states: initialized and
512// uninitialized. In ES5 only immutable bindings have these two states. When
513// accessing a binding, it needs to be checked for initialization. However in
514// the following cases the binding is initialized immediately after creation
515// so the initialization check can always be skipped:
516// 1. Var declared local variables.
517// var foo;
518// 2. A local variable introduced by a function declaration.
519// function foo() {}
520// 3. Parameters
521// function x(foo) {}
522// 4. Catch bound variables.
523// try {} catch (foo) {}
524// 6. Function variables of named function expressions.
525// var x = function foo() {}
526// 7. Implicit binding of 'this'.
527// 8. Implicit binding of 'arguments' in functions.
528//
529// ES5 specified object environment records which are introduced by ES elements
530// such as Program and WithStatement that associate identifier bindings with the
531// properties of some object. In the specification only mutable bindings exist
532// (which may be non-writable) and have no distinct initialization step. However
533// V8 allows const declarations in global code with distinct creation and
534// initialization steps which are represented by non-writable properties in the
535// global object. As a result also these bindings need to be checked for
536// initialization.
537//
538// The following enum specifies a flag that indicates if the binding needs a
539// distinct initialization step (kNeedsInitialization) or if the binding is
540// immediately initialized upon creation (kCreatedInitialized).
541enum InitializationFlag {
542 kNeedsInitialization,
543 kCreatedInitialized
544};
545
546
erik.corry@gmail.com394dbcf2011-10-27 07:38:48 +0000547enum ClearExceptionFlag {
548 KEEP_EXCEPTION,
549 CLEAR_EXCEPTION
550};
551
552
erik.corry@gmail.com4a6c3272010-11-18 12:04:40 +0000553} } // namespace v8::internal
554
555#endif // V8_V8GLOBALS_H_