source: webkit/trunk/JavaScriptCore/bytecode/CodeBlock.h@ 39070

Last change on this file since 39070 was 39070, checked in by [email protected], 16 years ago

2008-12-05 Sam Weinig <[email protected]>

Reviewed by Cameron Zwarich.

Fix for https://bugs.webkit.org/show_bug.cgi?id=22715
Encapsulate more CodeBlock members in preparation
of moving some of them to a rare data structure.

  • bytecode/CodeBlock.cpp: (JSC::locationForOffset): (JSC::printConditionalJump): (JSC::printGetByIdOp): (JSC::printPutByIdOp): (JSC::CodeBlock::printStructure): (JSC::CodeBlock::printStructures): (JSC::CodeBlock::dump): (JSC::CodeBlock::~CodeBlock): (JSC::CodeBlock::unlinkCallers): (JSC::CodeBlock::derefStructures): (JSC::CodeBlock::refStructures): (JSC::CodeBlock::mark): (JSC::CodeBlock::getHandlerForVPC): (JSC::CodeBlock::nativeExceptionCodeForHandlerVPC): (JSC::CodeBlock::lineNumberForVPC): (JSC::CodeBlock::expressionRangeForVPC): (JSC::CodeBlock::shrinkToFit):
  • bytecode/CodeBlock.h: (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::addCaller): (JSC::CodeBlock::removeCaller): (JSC::CodeBlock::isKnownNotImmediate): (JSC::CodeBlock::isConstantRegisterIndex): (JSC::CodeBlock::getConstant): (JSC::CodeBlock::isTemporaryRegisterIndex): (JSC::CodeBlock::getStubInfo): (JSC::CodeBlock::getCallLinkInfo): (JSC::CodeBlock::instructions): (JSC::CodeBlock::setJITCode): (JSC::CodeBlock::jitCode): (JSC::CodeBlock::ownerNode): (JSC::CodeBlock::setGlobalData): (JSC::CodeBlock::setThisRegister): (JSC::CodeBlock::thisRegister): (JSC::CodeBlock::setNeedsFullScopeChain): (JSC::CodeBlock::needsFullScopeChain): (JSC::CodeBlock::setUsesEval): (JSC::CodeBlock::usesEval): (JSC::CodeBlock::setUsesArguments): (JSC::CodeBlock::usesArguments): (JSC::CodeBlock::codeType): (JSC::CodeBlock::source): (JSC::CodeBlock::sourceOffset): (JSC::CodeBlock::addGlobalResolveInstruction): (JSC::CodeBlock::numberOfPropertyAccessInstructions): (JSC::CodeBlock::addPropertyAccessInstruction): (JSC::CodeBlock::propertyAccessInstruction): (JSC::CodeBlock::numberOfCallLinkInfos): (JSC::CodeBlock::addCallLinkInfo): (JSC::CodeBlock::callLinkInfo): (JSC::CodeBlock::numberOfJumpTargets): (JSC::CodeBlock::addJumpTarget): (JSC::CodeBlock::jumpTarget): (JSC::CodeBlock::lastJumpTarget): (JSC::CodeBlock::numberOfExceptionHandlers): (JSC::CodeBlock::addExceptionHandler): (JSC::CodeBlock::exceptionHandler): (JSC::CodeBlock::addExpressionInfo): (JSC::CodeBlock::numberOfLineInfos): (JSC::CodeBlock::addLineInfo): (JSC::CodeBlock::lastLineInfo): (JSC::CodeBlock::jitReturnAddressVPCMap): (JSC::CodeBlock::numberOfIdentifiers): (JSC::CodeBlock::addIdentifier): (JSC::CodeBlock::identifier): (JSC::CodeBlock::numberOfConstantRegisters): (JSC::CodeBlock::addConstantRegister): (JSC::CodeBlock::constantRegister): (JSC::CodeBlock::addFunction): (JSC::CodeBlock::function): (JSC::CodeBlock::addFunctionExpression): (JSC::CodeBlock::functionExpression): (JSC::CodeBlock::addUnexpectedConstant): (JSC::CodeBlock::unexpectedConstant): (JSC::CodeBlock::addRegExp): (JSC::CodeBlock::regexp): (JSC::CodeBlock::symbolTable): (JSC::CodeBlock::evalCodeCache): New inline setters/getters.

(JSC::ProgramCodeBlock::ProgramCodeBlock):
(JSC::ProgramCodeBlock::~ProgramCodeBlock):
(JSC::ProgramCodeBlock::clearGlobalObject):

  • bytecode/SamplingTool.cpp: (JSC::ScopeSampleRecord::sample): (JSC::SamplingTool::dump):
  • bytecompiler/BytecodeGenerator.cpp:
  • bytecompiler/BytecodeGenerator.h:
  • bytecompiler/Label.h:
  • interpreter/CallFrame.cpp:
  • interpreter/Interpreter.cpp:
  • jit/JIT.cpp:
  • jit/JITCall.cpp:
  • jit/JITInlineMethods.h:
  • jit/JITPropertyAccess.cpp:
  • parser/Nodes.cpp:
  • runtime/Arguments.h:
  • runtime/ExceptionHelpers.cpp:
  • runtime/JSActivation.cpp:
  • runtime/JSActivation.h:
  • runtime/JSGlobalObject.cpp: Change direct access to use new getter/setters.
File size: 19.2 KB
Line 
1/*
2 * Copyright (C) 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Cameron Zwarich <[email protected]>
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
15 * its contributors may be used to endorse or promote products derived
16 * from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30#ifndef CodeBlock_h
31#define CodeBlock_h
32
33#include "EvalCodeCache.h"
34#include "Instruction.h"
35#include "JSGlobalObject.h"
36#include "Nodes.h"
37#include "RegExp.h"
38#include "UString.h"
39#include <wtf/RefPtr.h>
40#include <wtf/Vector.h>
41
42namespace JSC {
43
44 class ExecState;
45
46 enum CodeType { GlobalCode, EvalCode, FunctionCode };
47
48 static ALWAYS_INLINE int missingThisObjectMarker() { return std::numeric_limits<int>::max(); }
49
50 struct HandlerInfo {
51 uint32_t start;
52 uint32_t end;
53 uint32_t target;
54 uint32_t scopeDepth;
55 void* nativeCode;
56 };
57
58 struct ExpressionRangeInfo {
59 enum {
60 MaxOffset = (1 << 7) - 1,
61 MaxDivot = (1 << 25) - 1
62 };
63 uint32_t instructionOffset : 25;
64 uint32_t divotPoint : 25;
65 uint32_t startOffset : 7;
66 uint32_t endOffset : 7;
67 };
68
69 struct LineInfo {
70 uint32_t instructionOffset;
71 int32_t lineNumber;
72 };
73
74 struct OffsetLocation {
75 int32_t branchOffset;
76#if ENABLE(JIT)
77 void* ctiOffset;
78#endif
79 };
80
81 struct StructureStubInfo {
82 StructureStubInfo(unsigned bytecodeIndex)
83 : bytecodeIndex(bytecodeIndex)
84 , stubRoutine(0)
85 , callReturnLocation(0)
86 , hotPathBegin(0)
87 {
88 }
89
90 unsigned bytecodeIndex;
91 void* stubRoutine;
92 void* callReturnLocation;
93 void* hotPathBegin;
94 };
95
96 struct CallLinkInfo {
97 CallLinkInfo()
98 : callReturnLocation(0)
99 , hotPathBegin(0)
100 , hotPathOther(0)
101 , coldPathOther(0)
102 , callee(0)
103 {
104 }
105
106 unsigned bytecodeIndex;
107 void* callReturnLocation;
108 void* hotPathBegin;
109 void* hotPathOther;
110 void* coldPathOther;
111 CodeBlock* callee;
112 unsigned position;
113
114 void setUnlinked() { callee = 0; }
115 bool isLinked() { return callee; }
116 };
117
118 inline void* getStructureStubInfoReturnLocation(StructureStubInfo* structureStubInfo)
119 {
120 return structureStubInfo->callReturnLocation;
121 }
122
123 inline void* getCallLinkInfoReturnLocation(CallLinkInfo* callLinkInfo)
124 {
125 return callLinkInfo->callReturnLocation;
126 }
127
128 // Binary chop algorithm, calls valueAtPosition on pre-sorted elements in array,
129 // compares result with key (KeyTypes should be comparable with '--', '<', '>').
130 // Optimized for cases where the array contains the key, checked by assertions.
131 template<typename ArrayType, typename KeyType, KeyType(*valueAtPosition)(ArrayType*)>
132 inline ArrayType* binaryChop(ArrayType* array, size_t size, KeyType key)
133 {
134 // The array must contain at least one element (pre-condition, array does conatin key).
135 // If the array only contains one element, no need to do the comparison.
136 while (size > 1) {
137 // Pick an element to check, half way through the array, and read the value.
138 int pos = (size - 1) >> 1;
139 KeyType val = valueAtPosition(&array[pos]);
140
141 // If the key matches, success!
142 if (val == key)
143 return &array[pos];
144 // The item we are looking for is smaller than the item being check; reduce the value of 'size',
145 // chopping off the right hand half of the array.
146 else if (key < val)
147 size = pos;
148 // Discard all values in the left hand half of the array, up to and including the item at pos.
149 else {
150 size -= (pos + 1);
151 array += (pos + 1);
152 }
153
154 // 'size' should never reach zero.
155 ASSERT(size);
156 }
157
158 // If we reach this point we've chopped down to one element, no need to check it matches
159 ASSERT(size == 1);
160 ASSERT(key == valueAtPosition(&array[0]));
161 return &array[0];
162 }
163
164 struct StringJumpTable {
165 typedef HashMap<RefPtr<UString::Rep>, OffsetLocation> StringOffsetTable;
166 StringOffsetTable offsetTable;
167#if ENABLE(JIT)
168 void* ctiDefault; // FIXME: it should not be necessary to store this.
169#endif
170
171 inline int32_t offsetForValue(UString::Rep* value, int32_t defaultOffset)
172 {
173 StringOffsetTable::const_iterator end = offsetTable.end();
174 StringOffsetTable::const_iterator loc = offsetTable.find(value);
175 if (loc == end)
176 return defaultOffset;
177 return loc->second.branchOffset;
178 }
179
180#if ENABLE(JIT)
181 inline void* ctiForValue(UString::Rep* value)
182 {
183 StringOffsetTable::const_iterator end = offsetTable.end();
184 StringOffsetTable::const_iterator loc = offsetTable.find(value);
185 if (loc == end)
186 return ctiDefault;
187 return loc->second.ctiOffset;
188 }
189#endif
190 };
191
192 struct SimpleJumpTable {
193 // FIXME: The two Vectors can be combind into one Vector<OffsetLocation>
194 Vector<int32_t> branchOffsets;
195 int32_t min;
196#if ENABLE(JIT)
197 Vector<void*> ctiOffsets;
198 void* ctiDefault;
199#endif
200
201 int32_t offsetForValue(int32_t value, int32_t defaultOffset);
202 void add(int32_t key, int32_t offset)
203 {
204 if (!branchOffsets[key])
205 branchOffsets[key] = offset;
206 }
207
208#if ENABLE(JIT)
209 inline void* ctiForValue(int32_t value)
210 {
211 if (value >= min && static_cast<uint32_t>(value - min) < ctiOffsets.size())
212 return ctiOffsets[value - min];
213 return ctiDefault;
214 }
215#endif
216 };
217
218 class CodeBlock {
219 friend class JIT;
220 public:
221 CodeBlock(ScopeNode* ownerNode, CodeType codeType, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset)
222 : m_numCalleeRegisters(0)
223 , m_numConstants(0)
224 , m_numVars(0)
225 , m_numParameters(0)
226 , m_ownerNode(ownerNode)
227 , m_globalData(0)
228#if ENABLE(JIT)
229 , m_jitCode(0)
230#endif
231 , m_needsFullScopeChain(ownerNode->needsActivation())
232 , m_usesEval(ownerNode->usesEval())
233 , m_codeType(codeType)
234 , m_source(sourceProvider)
235 , m_sourceOffset(sourceOffset)
236 {
237 ASSERT(m_source);
238 }
239
240 ~CodeBlock();
241
242#if ENABLE(JIT)
243 void unlinkCallers();
244#endif
245
246 void addCaller(CallLinkInfo* caller)
247 {
248 caller->callee = this;
249 caller->position = m_linkedCallerList.size();
250 m_linkedCallerList.append(caller);
251 }
252
253 void removeCaller(CallLinkInfo* caller)
254 {
255 unsigned pos = caller->position;
256 unsigned lastPos = m_linkedCallerList.size() - 1;
257
258 if (pos != lastPos) {
259 m_linkedCallerList[pos] = m_linkedCallerList[lastPos];
260 m_linkedCallerList[pos]->position = pos;
261 }
262 m_linkedCallerList.shrink(lastPos);
263 }
264
265 inline bool isKnownNotImmediate(int index)
266 {
267 if (index == m_thisRegister)
268 return true;
269
270 if (isConstantRegisterIndex(index))
271 return !JSImmediate::isImmediate(getConstant(index));
272
273 return false;
274 }
275
276 ALWAYS_INLINE bool isConstantRegisterIndex(int index)
277 {
278 return index >= m_numVars && index < m_numVars + m_numConstants;
279 }
280
281 ALWAYS_INLINE JSValue* getConstant(int index)
282 {
283 return m_constantRegisters[index - m_numVars].getJSValue();
284 }
285
286 ALWAYS_INLINE bool isTemporaryRegisterIndex(int index)
287 {
288 return index >= m_numVars + m_numConstants;
289 }
290
291#if !defined(NDEBUG) || ENABLE_OPCODE_SAMPLING
292 void dump(ExecState*) const;
293 void printStructures(const Instruction*) const;
294 void printStructure(const char* name, const Instruction*, int operand) const;
295#endif
296 int expressionRangeForVPC(const Instruction*, int& divot, int& startOffset, int& endOffset);
297 int lineNumberForVPC(const Instruction* vPC);
298 bool getHandlerForVPC(const Instruction* vPC, Instruction*& target, int& scopeDepth);
299 void* nativeExceptionCodeForHandlerVPC(const Instruction* handlerVPC);
300
301 void mark();
302 void refStructures(Instruction* vPC) const;
303 void derefStructures(Instruction* vPC) const;
304
305 StructureStubInfo& getStubInfo(void* returnAddress)
306 {
307 return *(binaryChop<StructureStubInfo, void*, getStructureStubInfoReturnLocation>(m_propertyAccessInstructions.begin(), m_propertyAccessInstructions.size(), returnAddress));
308 }
309
310 CallLinkInfo& getCallLinkInfo(void* returnAddress)
311 {
312 return *(binaryChop<CallLinkInfo, void*, getCallLinkInfoReturnLocation>(m_callLinkInfos.begin(), m_callLinkInfos.size(), returnAddress));
313 }
314
315
316 Vector<Instruction>& instructions() { return m_instructions; }
317#if ENABLE(JIT)
318 void setJITCode(void* jitCode) { m_jitCode = jitCode; }
319 void* jitCode() { return m_jitCode; }
320#endif
321
322 ScopeNode* ownerNode() const { return m_ownerNode; }
323
324 void setGlobalData(JSGlobalData* globalData) { m_globalData = globalData; }
325
326 void setThisRegister(int thisRegister) { m_thisRegister = thisRegister; }
327 int thisRegister() const { return m_thisRegister; }
328
329 void setNeedsFullScopeChain(bool needsFullScopeChain) { m_needsFullScopeChain = needsFullScopeChain; }
330 bool needsFullScopeChain() const { return m_needsFullScopeChain; }
331 void setUsesEval(bool usesEval) { m_usesEval = usesEval; }
332 bool usesEval() const { return m_usesEval; }
333 void setUsesArguments(bool usesArguments) { m_usesArguments = usesArguments; }
334 bool usesArguments() const { return m_usesArguments; }
335
336 CodeType codeType() const { return m_codeType; }
337
338 SourceProvider* source() const { return m_source.get(); }
339 unsigned sourceOffset() const { return m_sourceOffset; }
340
341 void addGlobalResolveInstruction(unsigned globalResolveInstructions) { m_globalResolveInstructions.append(globalResolveInstructions); }
342
343 size_t numberOfPropertyAccessInstructions() const { return m_propertyAccessInstructions.size(); }
344 void addPropertyAccessInstruction(unsigned propertyAccessInstructions) { m_propertyAccessInstructions.append(StructureStubInfo(propertyAccessInstructions)); }
345 StructureStubInfo& propertyAccessInstruction(int index) { return m_propertyAccessInstructions[index]; }
346
347 size_t numberOfCallLinkInfos() const { return m_callLinkInfos.size(); }
348 void addCallLinkInfo() { m_callLinkInfos.append(CallLinkInfo()); }
349 CallLinkInfo& callLinkInfo(int index) { return m_callLinkInfos[index]; }
350
351 size_t numberOfJumpTargets() const { return m_jumpTargets.size(); }
352 void addJumpTarget(unsigned jumpTarget) { m_jumpTargets.append(jumpTarget); }
353 unsigned jumpTarget(int index) const { return m_jumpTargets[index]; }
354 unsigned lastJumpTarget() const { return m_jumpTargets.last(); }
355
356 size_t numberOfExceptionHandlers() const { return m_exceptionHandlers.size(); }
357 void addExceptionHandler(const HandlerInfo& hanler) { return m_exceptionHandlers.append(hanler); }
358 HandlerInfo& exceptionHandler(int index) { return m_exceptionHandlers[index]; }
359
360 void addExpressionInfo(const ExpressionRangeInfo& expressionInfo) { return m_expressionInfo.append(expressionInfo); }
361
362 size_t numberOfLineInfos() const { return m_lineInfo.size(); }
363 void addLineInfo(const LineInfo& lineInfo) { return m_lineInfo.append(lineInfo); }
364 LineInfo& lastLineInfo() { return m_lineInfo.last(); }
365
366#if ENABLE(JIT)
367 HashMap<void*, unsigned>& jitReturnAddressVPCMap() { return m_jitReturnAddressVPCMap; }
368#endif
369
370 // Constant Pool
371
372 size_t numberOfIdentifiers() const { return m_identifiers.size(); }
373 void addIdentifier(const Identifier& i) { return m_identifiers.append(i); }
374 Identifier& identifier(int index) { return m_identifiers[index]; }
375
376 size_t numberOfConstantRegisters() const { return m_constantRegisters.size(); }
377 void addConstantRegister(const Register& r) { return m_constantRegisters.append(r); }
378 Register& constantRegister(int index) { return m_constantRegisters[index]; }
379
380 unsigned addFunction(FuncDeclNode* n) { unsigned size = m_functions.size(); m_functions.append(n); return size; }
381 FuncDeclNode* function(int index) const { return m_functions[index].get(); }
382
383 unsigned addFunctionExpression(FuncExprNode* n) { unsigned size = m_functionExpressions.size(); m_functionExpressions.append(n); return size; }
384 FuncExprNode* functionExpression(int index) const { return m_functionExpressions[index].get(); }
385
386 unsigned addUnexpectedConstant(JSValue* v) { unsigned size = m_unexpectedConstants.size(); m_unexpectedConstants.append(v); return size; }
387 JSValue* unexpectedConstant(int index) const { return m_unexpectedConstants[index]; }
388
389 unsigned addRegExp(RegExp* r) { unsigned size = m_regexps.size(); m_regexps.append(r); return size; }
390 RegExp* regexp(int index) const { return m_regexps[index].get(); }
391
392 // Jump Tables
393
394 size_t numberOfImmediateSwitchJumpTables() const { return m_immediateSwitchJumpTables.size(); }
395 SimpleJumpTable& addImmediateSwitchJumpTable() { m_immediateSwitchJumpTables.append(SimpleJumpTable()); return m_immediateSwitchJumpTables.last(); }
396 SimpleJumpTable& immediateSwitchJumpTable(int tableIndex) { return m_immediateSwitchJumpTables[tableIndex]; }
397
398 size_t numberOfCharacterSwitchJumpTables() const { return m_characterSwitchJumpTables.size(); }
399 SimpleJumpTable& addCharacterSwitchJumpTable() { m_characterSwitchJumpTables.append(SimpleJumpTable()); return m_characterSwitchJumpTables.last(); }
400 SimpleJumpTable& characterSwitchJumpTable(int tableIndex) { return m_characterSwitchJumpTables[tableIndex]; }
401
402 size_t numberOfStringSwitchJumpTables() const { return m_stringSwitchJumpTables.size(); }
403 StringJumpTable& addStringSwitchJumpTable() { m_stringSwitchJumpTables.append(StringJumpTable()); return m_stringSwitchJumpTables.last(); }
404 StringJumpTable& stringSwitchJumpTable(int tableIndex) { return m_stringSwitchJumpTables[tableIndex]; }
405
406
407 SymbolTable& symbolTable() { return m_symbolTable; }
408 EvalCodeCache& evalCodeCache() { return m_evalCodeCache; }
409
410 void shrinkToFit();
411
412 // FIXME: Make these remaining members private.
413
414 int m_numCalleeRegisters;
415 // NOTE: numConstants holds the number of constant registers allocated
416 // by the code generator, not the number of constant registers used.
417 // (Duplicate constants are uniqued during code generation, and spare
418 // constant registers may be allocated.)
419 int m_numConstants;
420 int m_numVars;
421 int m_numParameters;
422
423 private:
424#if !defined(NDEBUG) || ENABLE(OPCODE_SAMPLING)
425 void dump(ExecState*, const Vector<Instruction>::const_iterator& begin, Vector<Instruction>::const_iterator&) const;
426#endif
427
428 ScopeNode* m_ownerNode;
429 JSGlobalData* m_globalData;
430
431 Vector<Instruction> m_instructions;
432#if ENABLE(JIT)
433 void* m_jitCode;
434#endif
435
436 int m_thisRegister;
437
438 bool m_needsFullScopeChain;
439 bool m_usesEval;
440 bool m_usesArguments;
441
442 CodeType m_codeType;
443
444 RefPtr<SourceProvider> m_source;
445 unsigned m_sourceOffset;
446
447 Vector<unsigned> m_globalResolveInstructions;
448 Vector<StructureStubInfo> m_propertyAccessInstructions;
449 Vector<CallLinkInfo> m_callLinkInfos;
450 Vector<CallLinkInfo*> m_linkedCallerList;
451
452 Vector<unsigned> m_jumpTargets;
453
454 Vector<HandlerInfo> m_exceptionHandlers;
455 Vector<ExpressionRangeInfo> m_expressionInfo;
456 Vector<LineInfo> m_lineInfo;
457
458#if ENABLE(JIT)
459 HashMap<void*, unsigned> m_jitReturnAddressVPCMap;
460#endif
461
462 // Constant Pool
463 Vector<Identifier> m_identifiers;
464 Vector<Register> m_constantRegisters;
465 Vector<RefPtr<FuncDeclNode> > m_functions;
466 Vector<RefPtr<FuncExprNode> > m_functionExpressions;
467 Vector<JSValue*> m_unexpectedConstants;
468 Vector<RefPtr<RegExp> > m_regexps;
469
470 // Jump Tables
471 Vector<SimpleJumpTable> m_immediateSwitchJumpTables;
472 Vector<SimpleJumpTable> m_characterSwitchJumpTables;
473 Vector<StringJumpTable> m_stringSwitchJumpTables;
474
475 SymbolTable m_symbolTable;
476
477 EvalCodeCache m_evalCodeCache;
478 };
479
480 // Program code is not marked by any function, so we make the global object
481 // responsible for marking it.
482
483 class ProgramCodeBlock : public CodeBlock {
484 public:
485 ProgramCodeBlock(ScopeNode* ownerNode, CodeType codeType, JSGlobalObject* globalObject, PassRefPtr<SourceProvider> sourceProvider)
486 : CodeBlock(ownerNode, codeType, sourceProvider, 0)
487 , m_globalObject(globalObject)
488 {
489 m_globalObject->codeBlocks().add(this);
490 }
491
492 ~ProgramCodeBlock()
493 {
494 if (m_globalObject)
495 m_globalObject->codeBlocks().remove(this);
496 }
497
498 void clearGlobalObject() { m_globalObject = 0; }
499
500 private:
501 JSGlobalObject* m_globalObject; // For program and eval nodes, the global object that marks the constant pool.
502 };
503
504 class EvalCodeBlock : public ProgramCodeBlock {
505 public:
506 EvalCodeBlock(ScopeNode* ownerNode, JSGlobalObject* globalObject, PassRefPtr<SourceProvider> sourceProvider)
507 : ProgramCodeBlock(ownerNode, EvalCode, globalObject, sourceProvider)
508 {
509 }
510 };
511
512} // namespace JSC
513
514#endif // CodeBlock_h
Note: See TracBrowser for help on using the repository browser.