Remove the unused *Executable::unlinkCalls() and CodeBlock::unlinkCalls()
[WebKit-https.git] / Source / JavaScriptCore / runtime / Executable.h
1 /*
2  * Copyright (C) 2009, 2010, 2013-2015 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
24  */
25
26 #ifndef Executable_h
27 #define Executable_h
28
29 #include "ArityCheckMode.h"
30 #include "CallData.h"
31 #include "CodeBlockHash.h"
32 #include "CodeSpecializationKind.h"
33 #include "CompilationResult.h"
34 #include "DFGPlan.h"
35 #include "ExecutableInfo.h"
36 #include "HandlerInfo.h"
37 #include "InferredValue.h"
38 #include "JITCode.h"
39 #include "JSGlobalObject.h"
40 #include "RegisterPreservationMode.h"
41 #include "SamplingTool.h"
42 #include "SourceCode.h"
43 #include "TypeSet.h"
44 #include "UnlinkedCodeBlock.h"
45 #include "UnlinkedFunctionExecutable.h"
46
47 namespace JSC {
48
49 class CodeBlock;
50 class Debugger;
51 class EvalCodeBlock;
52 class FunctionCodeBlock;
53 class LLIntOffsetsExtractor;
54 class ProgramCodeBlock;
55 class JSScope;
56     
57 enum CompilationKind { FirstCompilation, OptimizingCompilation };
58
59 inline bool isCall(CodeSpecializationKind kind)
60 {
61     if (kind == CodeForCall)
62         return true;
63     ASSERT(kind == CodeForConstruct);
64     return false;
65 }
66
67 class ExecutableBase : public JSCell {
68     friend class JIT;
69
70 protected:
71     static const int NUM_PARAMETERS_IS_HOST = 0;
72     static const int NUM_PARAMETERS_NOT_COMPILED = -1;
73
74     ExecutableBase(VM& vm, Structure* structure, int numParameters)
75         : JSCell(vm, structure)
76         , m_numParametersForCall(numParameters)
77         , m_numParametersForConstruct(numParameters)
78     {
79     }
80
81     void finishCreation(VM& vm)
82     {
83         Base::finishCreation(vm);
84     }
85
86 public:
87     typedef JSCell Base;
88     static const unsigned StructureFlags = Base::StructureFlags;
89
90     static const bool needsDestruction = true;
91     static void destroy(JSCell*);
92         
93     CodeBlockHash hashFor(CodeSpecializationKind) const;
94
95     bool isEvalExecutable()
96     {
97         return type() == EvalExecutableType;
98     }
99     bool isFunctionExecutable()
100     {
101         return type() == FunctionExecutableType;
102     }
103     bool isProgramExecutable()
104     {
105         return type() == ProgramExecutableType;
106     }
107
108     bool isHostFunction() const
109     {
110         ASSERT((m_numParametersForCall == NUM_PARAMETERS_IS_HOST) == (m_numParametersForConstruct == NUM_PARAMETERS_IS_HOST));
111         return m_numParametersForCall == NUM_PARAMETERS_IS_HOST;
112     }
113
114     static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue proto) { return Structure::create(vm, globalObject, proto, TypeInfo(CellType, StructureFlags), info()); }
115         
116     void clearCode();
117
118     DECLARE_EXPORT_INFO;
119
120 protected:
121     int m_numParametersForCall;
122     int m_numParametersForConstruct;
123
124 public:
125     static void clearCodeVirtual(ExecutableBase*);
126
127     PassRefPtr<JITCode> generatedJITCodeForCall()
128     {
129         ASSERT(m_jitCodeForCall);
130         return m_jitCodeForCall;
131     }
132
133     PassRefPtr<JITCode> generatedJITCodeForConstruct()
134     {
135         ASSERT(m_jitCodeForConstruct);
136         return m_jitCodeForConstruct;
137     }
138         
139     PassRefPtr<JITCode> generatedJITCodeFor(CodeSpecializationKind kind)
140     {
141         if (kind == CodeForCall)
142             return generatedJITCodeForCall();
143         ASSERT(kind == CodeForConstruct);
144         return generatedJITCodeForConstruct();
145     }
146     
147     MacroAssemblerCodePtr entrypointFor(
148         VM& vm, CodeSpecializationKind kind, ArityCheckMode arity, RegisterPreservationMode registers)
149     {
150         // Check if we have a cached result. We only have it for arity check because we use the
151         // no-arity entrypoint in non-virtual calls, which will "cache" this value directly in
152         // machine code.
153         if (arity == MustCheckArity) {
154             switch (kind) {
155             case CodeForCall:
156                 switch (registers) {
157                 case RegisterPreservationNotRequired:
158                     if (MacroAssemblerCodePtr result = m_jitCodeForCallWithArityCheck)
159                         return result;
160                     break;
161                 case MustPreserveRegisters:
162                     if (MacroAssemblerCodePtr result = m_jitCodeForCallWithArityCheckAndPreserveRegs)
163                         return result;
164                     break;
165                 }
166                 break;
167             case CodeForConstruct:
168                 switch (registers) {
169                 case RegisterPreservationNotRequired:
170                     if (MacroAssemblerCodePtr result = m_jitCodeForConstructWithArityCheck)
171                         return result;
172                     break;
173                 case MustPreserveRegisters:
174                     if (MacroAssemblerCodePtr result = m_jitCodeForConstructWithArityCheckAndPreserveRegs)
175                         return result;
176                     break;
177                 }
178                 break;
179             }
180         }
181         MacroAssemblerCodePtr result =
182             generatedJITCodeFor(kind)->addressForCall(vm, this, arity, registers);
183         if (arity == MustCheckArity) {
184             // Cache the result; this is necessary for the JIT's virtual call optimizations.
185             switch (kind) {
186             case CodeForCall:
187                 switch (registers) {
188                 case RegisterPreservationNotRequired:
189                     m_jitCodeForCallWithArityCheck = result;
190                     break;
191                 case MustPreserveRegisters:
192                     m_jitCodeForCallWithArityCheckAndPreserveRegs = result;
193                     break;
194                 }
195                 break;
196             case CodeForConstruct:
197                 switch (registers) {
198                 case RegisterPreservationNotRequired:
199                     m_jitCodeForConstructWithArityCheck = result;
200                     break;
201                 case MustPreserveRegisters:
202                     m_jitCodeForConstructWithArityCheckAndPreserveRegs = result;
203                     break;
204                 }
205                 break;
206             }
207         }
208         return result;
209     }
210
211     static ptrdiff_t offsetOfJITCodeWithArityCheckFor(
212         CodeSpecializationKind kind, RegisterPreservationMode registers)
213     {
214         switch (kind) {
215         case CodeForCall:
216             switch (registers) {
217             case RegisterPreservationNotRequired:
218                 return OBJECT_OFFSETOF(ExecutableBase, m_jitCodeForCallWithArityCheck);
219             case MustPreserveRegisters:
220                 return OBJECT_OFFSETOF(ExecutableBase, m_jitCodeForCallWithArityCheckAndPreserveRegs);
221             }
222         case CodeForConstruct:
223             switch (registers) {
224             case RegisterPreservationNotRequired:
225                 return OBJECT_OFFSETOF(ExecutableBase, m_jitCodeForConstructWithArityCheck);
226             case MustPreserveRegisters:
227                 return OBJECT_OFFSETOF(ExecutableBase, m_jitCodeForConstructWithArityCheckAndPreserveRegs);
228             }
229         }
230         RELEASE_ASSERT_NOT_REACHED();
231         return 0;
232     }
233     
234     static ptrdiff_t offsetOfNumParametersFor(CodeSpecializationKind kind)
235     {
236         if (kind == CodeForCall)
237             return OBJECT_OFFSETOF(ExecutableBase, m_numParametersForCall);
238         ASSERT(kind == CodeForConstruct);
239         return OBJECT_OFFSETOF(ExecutableBase, m_numParametersForConstruct);
240     }
241
242     bool hasJITCodeForCall() const
243     {
244         return m_numParametersForCall >= 0;
245     }
246         
247     bool hasJITCodeForConstruct() const
248     {
249         return m_numParametersForConstruct >= 0;
250     }
251         
252     bool hasJITCodeFor(CodeSpecializationKind kind) const
253     {
254         if (kind == CodeForCall)
255             return hasJITCodeForCall();
256         ASSERT(kind == CodeForConstruct);
257         return hasJITCodeForConstruct();
258     }
259
260     // Intrinsics are only for calls, currently.
261     Intrinsic intrinsic() const;
262         
263     Intrinsic intrinsicFor(CodeSpecializationKind kind) const
264     {
265         if (isCall(kind))
266             return intrinsic();
267         return NoIntrinsic;
268     }
269     
270     void dump(PrintStream&) const;
271         
272 protected:
273     RefPtr<JITCode> m_jitCodeForCall;
274     RefPtr<JITCode> m_jitCodeForConstruct;
275     MacroAssemblerCodePtr m_jitCodeForCallWithArityCheck;
276     MacroAssemblerCodePtr m_jitCodeForConstructWithArityCheck;
277     MacroAssemblerCodePtr m_jitCodeForCallWithArityCheckAndPreserveRegs;
278     MacroAssemblerCodePtr m_jitCodeForConstructWithArityCheckAndPreserveRegs;
279 };
280
281 class NativeExecutable final : public ExecutableBase {
282     friend class JIT;
283     friend class LLIntOffsetsExtractor;
284 public:
285     typedef ExecutableBase Base;
286     static const unsigned StructureFlags = Base::StructureFlags | StructureIsImmortal;
287
288     static NativeExecutable* create(VM& vm, PassRefPtr<JITCode> callThunk, NativeFunction function, PassRefPtr<JITCode> constructThunk, NativeFunction constructor, Intrinsic intrinsic)
289     {
290         NativeExecutable* executable;
291         executable = new (NotNull, allocateCell<NativeExecutable>(vm.heap)) NativeExecutable(vm, function, constructor);
292         executable->finishCreation(vm, callThunk, constructThunk, intrinsic);
293         return executable;
294     }
295
296     static void destroy(JSCell*);
297
298     CodeBlockHash hashFor(CodeSpecializationKind) const;
299
300     NativeFunction function() { return m_function; }
301     NativeFunction constructor() { return m_constructor; }
302         
303     NativeFunction nativeFunctionFor(CodeSpecializationKind kind)
304     {
305         if (kind == CodeForCall)
306             return function();
307         ASSERT(kind == CodeForConstruct);
308         return constructor();
309     }
310         
311     static ptrdiff_t offsetOfNativeFunctionFor(CodeSpecializationKind kind)
312     {
313         if (kind == CodeForCall)
314             return OBJECT_OFFSETOF(NativeExecutable, m_function);
315         ASSERT(kind == CodeForConstruct);
316         return OBJECT_OFFSETOF(NativeExecutable, m_constructor);
317     }
318
319     static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue proto) { return Structure::create(vm, globalObject, proto, TypeInfo(CellType, StructureFlags), info()); }
320         
321     DECLARE_INFO;
322
323     Intrinsic intrinsic() const;
324
325 protected:
326     void finishCreation(VM& vm, PassRefPtr<JITCode> callThunk, PassRefPtr<JITCode> constructThunk, Intrinsic intrinsic)
327     {
328         Base::finishCreation(vm);
329         m_jitCodeForCall = callThunk;
330         m_jitCodeForConstruct = constructThunk;
331         m_intrinsic = intrinsic;
332     }
333
334 private:
335     NativeExecutable(VM& vm, NativeFunction function, NativeFunction constructor)
336         : ExecutableBase(vm, vm.nativeExecutableStructure.get(), NUM_PARAMETERS_IS_HOST)
337         , m_function(function)
338         , m_constructor(constructor)
339     {
340     }
341
342     NativeFunction m_function;
343     NativeFunction m_constructor;
344         
345     Intrinsic m_intrinsic;
346 };
347
348 class ScriptExecutable : public ExecutableBase {
349 public:
350     typedef ExecutableBase Base;
351     static const unsigned StructureFlags = Base::StructureFlags;
352
353     static void destroy(JSCell*);
354         
355     CodeBlockHash hashFor(CodeSpecializationKind) const;
356
357     const SourceCode& source() const { return m_source; }
358     intptr_t sourceID() const { return m_source.providerID(); }
359     const String& sourceURL() const { return m_source.provider()->url(); }
360     int firstLine() const { return m_firstLine; }
361     void setOverrideLineNumber(int overrideLineNumber) { m_overrideLineNumber = overrideLineNumber; }
362     bool hasOverrideLineNumber() const { return m_overrideLineNumber != -1; }
363     int overrideLineNumber() const { return m_overrideLineNumber; }
364     int lastLine() const { return m_lastLine; }
365     unsigned startColumn() const { return m_startColumn; }
366     unsigned endColumn() const { return m_endColumn; }
367     unsigned typeProfilingStartOffset() const { return m_typeProfilingStartOffset; }
368     unsigned typeProfilingEndOffset() const { return m_typeProfilingEndOffset; }
369
370     bool usesEval() const { return m_features & EvalFeature; }
371     bool usesArguments() const { return m_features & ArgumentsFeature; }
372     bool needsActivation() const { return m_hasCapturedVariables || m_features & (EvalFeature | WithFeature | CatchFeature); }
373     bool isStrictMode() const { return m_features & StrictModeFeature; }
374     ECMAMode ecmaMode() const { return isStrictMode() ? StrictMode : NotStrictMode; }
375         
376     void setNeverInline(bool value) { m_neverInline = value; }
377     void setDidTryToEnterInLoop(bool value) { m_didTryToEnterInLoop = value; }
378     bool neverInline() const { return m_neverInline; }
379     bool didTryToEnterInLoop() const { return m_didTryToEnterInLoop; }
380     bool isInliningCandidate() const { return !neverInline(); }
381     
382     bool* addressOfDidTryToEnterInLoop() { return &m_didTryToEnterInLoop; }
383
384     CodeFeatures features() const { return m_features; }
385         
386     DECLARE_INFO;
387
388     void recordParse(CodeFeatures features, bool hasCapturedVariables, int firstLine, int lastLine, unsigned startColumn, unsigned endColumn)
389     {
390         m_features = features;
391         m_hasCapturedVariables = hasCapturedVariables;
392         m_firstLine = firstLine;
393         m_lastLine = lastLine;
394         ASSERT(startColumn != UINT_MAX);
395         m_startColumn = startColumn;
396         ASSERT(endColumn != UINT_MAX);
397         m_endColumn = endColumn;
398     }
399
400     void installCode(CodeBlock*);
401     RefPtr<CodeBlock> newCodeBlockFor(CodeSpecializationKind, JSFunction*, JSScope*, JSObject*& exception);
402     PassRefPtr<CodeBlock> newReplacementCodeBlockFor(CodeSpecializationKind);
403     
404     JSObject* prepareForExecution(ExecState* exec, JSFunction* function, JSScope* scope, CodeSpecializationKind kind)
405     {
406         if (hasJITCodeFor(kind))
407             return 0;
408         return prepareForExecutionImpl(exec, function, scope, kind);
409     }
410
411     template <typename Functor> void forEachCodeBlock(Functor&&);
412
413 private:
414     JSObject* prepareForExecutionImpl(ExecState*, JSFunction*, JSScope*, CodeSpecializationKind);
415
416 protected:
417     ScriptExecutable(Structure* structure, VM& vm, const SourceCode& source, bool isInStrictContext);
418
419     void finishCreation(VM& vm)
420     {
421         Base::finishCreation(vm);
422         vm.heap.addExecutable(this); // Balanced by Heap::deleteUnmarkedCompiledCode().
423
424 #if ENABLE(CODEBLOCK_SAMPLING)
425         if (SamplingTool* sampler = vm.interpreter->sampler())
426             sampler->notifyOfScope(vm, this);
427 #endif
428     }
429
430     SourceCode m_source;
431     CodeFeatures m_features;
432     bool m_hasCapturedVariables;
433     bool m_neverInline;
434     bool m_didTryToEnterInLoop;
435     int m_overrideLineNumber;
436     int m_firstLine;
437     int m_lastLine;
438     unsigned m_startColumn;
439     unsigned m_endColumn;
440     unsigned m_typeProfilingStartOffset;
441     unsigned m_typeProfilingEndOffset;
442 };
443
444 class EvalExecutable final : public ScriptExecutable {
445     friend class LLIntOffsetsExtractor;
446 public:
447     typedef ScriptExecutable Base;
448     static const unsigned StructureFlags = Base::StructureFlags | StructureIsImmortal;
449
450     static void destroy(JSCell*);
451
452     EvalCodeBlock* codeBlock()
453     {
454         return m_evalCodeBlock.get();
455     }
456
457     static EvalExecutable* create(ExecState*, const SourceCode&, bool isInStrictContext, ThisTDZMode, const VariableEnvironment*);
458
459     PassRefPtr<JITCode> generatedJITCode()
460     {
461         return generatedJITCodeForCall();
462     }
463
464     static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue proto)
465     {
466         return Structure::create(vm, globalObject, proto, TypeInfo(EvalExecutableType, StructureFlags), info());
467     }
468         
469     DECLARE_INFO;
470
471     void clearCode();
472
473     ExecutableInfo executableInfo() const { return ExecutableInfo(needsActivation(), usesEval(), isStrictMode(), false, false, ConstructorKind::None, false); }
474
475     unsigned numVariables() { return m_unlinkedEvalCodeBlock->numVariables(); }
476     unsigned numberOfFunctionDecls() { return m_unlinkedEvalCodeBlock->numberOfFunctionDecls(); }
477
478 private:
479     friend class ScriptExecutable;
480     EvalExecutable(ExecState*, const SourceCode&, bool);
481
482     static void visitChildren(JSCell*, SlotVisitor&);
483
484     RefPtr<EvalCodeBlock> m_evalCodeBlock;
485     WriteBarrier<UnlinkedEvalCodeBlock> m_unlinkedEvalCodeBlock;
486 };
487
488 class ProgramExecutable final : public ScriptExecutable {
489     friend class LLIntOffsetsExtractor;
490 public:
491     typedef ScriptExecutable Base;
492     static const unsigned StructureFlags = Base::StructureFlags | StructureIsImmortal;
493
494     static ProgramExecutable* create(ExecState* exec, const SourceCode& source)
495     {
496         ProgramExecutable* executable = new (NotNull, allocateCell<ProgramExecutable>(*exec->heap())) ProgramExecutable(exec, source);
497         executable->finishCreation(exec->vm());
498         return executable;
499     }
500
501
502     JSObject* initializeGlobalProperties(VM&, CallFrame*, JSScope*);
503
504     static void destroy(JSCell*);
505
506     ProgramCodeBlock* codeBlock()
507     {
508         return m_programCodeBlock.get();
509     }
510
511     JSObject* checkSyntax(ExecState*);
512
513     PassRefPtr<JITCode> generatedJITCode()
514     {
515         return generatedJITCodeForCall();
516     }
517         
518     static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue proto)
519     {
520         return Structure::create(vm, globalObject, proto, TypeInfo(ProgramExecutableType, StructureFlags), info());
521     }
522         
523     DECLARE_INFO;
524
525     void clearCode();
526
527     ExecutableInfo executableInfo() const { return ExecutableInfo(needsActivation(), usesEval(), isStrictMode(), false, false, ConstructorKind::None, false); }
528
529 private:
530     friend class ScriptExecutable;
531
532     ProgramExecutable(ExecState*, const SourceCode&);
533
534     static void visitChildren(JSCell*, SlotVisitor&);
535
536     WriteBarrier<UnlinkedProgramCodeBlock> m_unlinkedProgramCodeBlock;
537     RefPtr<ProgramCodeBlock> m_programCodeBlock;
538 };
539
540 class FunctionExecutable final : public ScriptExecutable {
541     friend class JIT;
542     friend class LLIntOffsetsExtractor;
543 public:
544     typedef ScriptExecutable Base;
545     static const unsigned StructureFlags = Base::StructureFlags | StructureIsImmortal;
546
547     static FunctionExecutable* create(
548         VM& vm, const SourceCode& source, UnlinkedFunctionExecutable* unlinkedExecutable, 
549         unsigned firstLine, unsigned lastLine, unsigned startColumn, unsigned endColumn)
550     {
551         FunctionExecutable* executable = new (NotNull, allocateCell<FunctionExecutable>(vm.heap)) FunctionExecutable(vm, source, unlinkedExecutable, firstLine, lastLine, startColumn, endColumn);
552         executable->finishCreation(vm);
553         return executable;
554     }
555     static FunctionExecutable* fromGlobalCode(
556         const Identifier& name, ExecState&, const SourceCode&, 
557         JSObject*& exception, int overrideLineNumber);
558
559     static void destroy(JSCell*);
560         
561     UnlinkedFunctionExecutable* unlinkedExecutable()
562     {
563         return m_unlinkedExecutable.get();
564     }
565
566     // Returns either call or construct bytecode. This can be appropriate
567     // for answering questions that that don't vary between call and construct --
568     // for example, argumentsRegister().
569     FunctionCodeBlock* eitherCodeBlock()
570     {
571         if (m_codeBlockForCall)
572             return m_codeBlockForCall.get();
573         return m_codeBlockForConstruct.get();
574     }
575         
576     bool isGeneratedForCall() const
577     {
578         return m_codeBlockForCall;
579     }
580
581     FunctionCodeBlock* codeBlockForCall()
582     {
583         return m_codeBlockForCall.get();
584     }
585
586     bool isGeneratedForConstruct() const
587     {
588         return m_codeBlockForConstruct;
589     }
590
591     FunctionCodeBlock* codeBlockForConstruct()
592     {
593         return m_codeBlockForConstruct.get();
594     }
595         
596     bool isGeneratedFor(CodeSpecializationKind kind)
597     {
598         if (kind == CodeForCall)
599             return isGeneratedForCall();
600         ASSERT(kind == CodeForConstruct);
601         return isGeneratedForConstruct();
602     }
603         
604     FunctionCodeBlock* codeBlockFor(CodeSpecializationKind kind)
605     {
606         if (kind == CodeForCall)
607             return codeBlockForCall();
608         ASSERT(kind == CodeForConstruct);
609         return codeBlockForConstruct();
610     }
611
612     FunctionCodeBlock* baselineCodeBlockFor(CodeSpecializationKind);
613         
614     FunctionCodeBlock* profiledCodeBlockFor(CodeSpecializationKind kind)
615     {
616         return baselineCodeBlockFor(kind);
617     }
618
619     RefPtr<TypeSet> returnStatementTypeSet() 
620     {
621         if (!m_returnStatementTypeSet)
622             m_returnStatementTypeSet = TypeSet::create();
623
624         return m_returnStatementTypeSet;
625     }
626         
627     FunctionMode functionMode() { return m_unlinkedExecutable->functionMode(); }
628     bool isBuiltinFunction() const { return m_unlinkedExecutable->isBuiltinFunction(); }
629     ConstructAbility constructAbility() const { return m_unlinkedExecutable->constructAbility(); }
630     bool isArrowFunction() const { return m_unlinkedExecutable->isArrowFunction(); }
631     bool isClassConstructorFunction() const { return m_unlinkedExecutable->isClassConstructorFunction(); }
632     const Identifier& name() { return m_unlinkedExecutable->name(); }
633     const Identifier& inferredName() { return m_unlinkedExecutable->inferredName(); }
634     JSString* nameValue() const { return m_unlinkedExecutable->nameValue(); }
635     size_t parameterCount() const { return m_unlinkedExecutable->parameterCount(); } // Excluding 'this'!
636
637     static void visitChildren(JSCell*, SlotVisitor&);
638     static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue proto)
639     {
640         return Structure::create(vm, globalObject, proto, TypeInfo(FunctionExecutableType, StructureFlags), info());
641     }
642
643     unsigned parametersStartOffset() const { return m_parametersStartOffset; }
644
645     void overrideParameterAndTypeProfilingStartEndOffsets(unsigned parametersStartOffset, unsigned typeProfilingStartOffset, unsigned typeProfilingEndOffset)
646     {
647         m_parametersStartOffset = parametersStartOffset;
648         m_typeProfilingStartOffset = typeProfilingStartOffset;
649         m_typeProfilingEndOffset = typeProfilingEndOffset;
650     }
651
652     DECLARE_INFO;
653
654     void clearCode();
655     
656     InferredValue* singletonFunction() { return m_singletonFunction.get(); }
657
658 private:
659     FunctionExecutable(
660         VM&, const SourceCode&, UnlinkedFunctionExecutable*, unsigned firstLine, 
661         unsigned lastLine, unsigned startColumn, unsigned endColumn);
662     
663     void finishCreation(VM&);
664
665     friend class ScriptExecutable;
666     
667     WriteBarrier<UnlinkedFunctionExecutable> m_unlinkedExecutable;
668     RefPtr<FunctionCodeBlock> m_codeBlockForCall;
669     RefPtr<FunctionCodeBlock> m_codeBlockForConstruct;
670     RefPtr<TypeSet> m_returnStatementTypeSet;
671     unsigned m_parametersStartOffset;
672     WriteBarrier<InferredValue> m_singletonFunction;
673 };
674
675 inline void ExecutableBase::clearCodeVirtual(ExecutableBase* executable)
676 {
677     switch (executable->type()) {
678     case EvalExecutableType:
679         return jsCast<EvalExecutable*>(executable)->clearCode();
680     case ProgramExecutableType:
681         return jsCast<ProgramExecutable*>(executable)->clearCode();
682     case FunctionExecutableType:
683         return jsCast<FunctionExecutable*>(executable)->clearCode();
684     default:
685         return jsCast<NativeExecutable*>(executable)->clearCode();
686     }
687 }
688
689 }
690
691 #endif