ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 1 | /* |
mark.lam@apple.com | 60c090d | 2019-03-07 10:16:58 +0000 | [diff] [blame] | 2 | * Copyright (C) 2009-2019 Apple Inc. All rights reserved. |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 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 | #include "config.h" |
| 27 | |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 28 | #include "CodeBlock.h" |
| 29 | #include "Debugger.h" |
ggaren@apple.com | a7cd139 | 2016-11-02 22:19:39 +0000 | [diff] [blame] | 30 | #include "EvalCodeBlock.h" |
| 31 | #include "FunctionCodeBlock.h" |
ysuzuki@apple.com | 5ff64dc | 2019-03-22 07:14:43 +0000 | [diff] [blame] | 32 | #include "GlobalExecutable.h" |
mark.lam@apple.com | 38aca1d | 2018-06-21 15:09:40 +0000 | [diff] [blame] | 33 | #include "IsoCellSetInlines.h" |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 34 | #include "JIT.h" |
ysuzuki@apple.com | e583634 | 2019-05-07 22:15:59 +0000 | [diff] [blame] | 35 | #include "JSTemplateObjectDescriptor.h" |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 36 | #include "LLIntEntrypoint.h" |
ggaren@apple.com | a7cd139 | 2016-11-02 22:19:39 +0000 | [diff] [blame] | 37 | #include "ModuleProgramCodeBlock.h" |
ross.kirsling@sony.com | 0ebe33c | 2020-05-15 19:39:36 +0000 | [diff] [blame] | 38 | #include "ParserError.h" |
ggaren@apple.com | a7cd139 | 2016-11-02 22:19:39 +0000 | [diff] [blame] | 39 | #include "ProgramCodeBlock.h" |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 40 | #include "VMInlines.h" |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 41 | |
| 42 | namespace JSC { |
| 43 | |
utatane.tea@gmail.com | a5544f1 | 2017-05-19 09:23:20 +0000 | [diff] [blame] | 44 | const ClassInfo ScriptExecutable::s_info = { "ScriptExecutable", &ExecutableBase::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(ScriptExecutable) }; |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 45 | |
tzagallo@apple.com | 30abe89 | 2020-03-27 18:39:46 +0000 | [diff] [blame] | 46 | ScriptExecutable::ScriptExecutable(Structure* structure, VM& vm, const SourceCode& source, bool isInStrictContext, DerivedContextType derivedContextType, bool isInArrowFunctionContext, bool isInsideOrdinaryFunction, EvalContextType evalContextType, Intrinsic intrinsic) |
ysuzuki@apple.com | 6189a49 | 2019-02-06 19:49:04 +0000 | [diff] [blame] | 47 | : ExecutableBase(vm, structure) |
| 48 | , m_source(source) |
| 49 | , m_intrinsic(intrinsic) |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 50 | , m_features(isInStrictContext ? StrictModeFeature : 0) |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 51 | , m_hasCapturedVariables(false) |
| 52 | , m_neverInline(false) |
| 53 | , m_neverOptimize(false) |
| 54 | , m_neverFTLOptimize(false) |
| 55 | , m_isArrowFunctionContext(isInArrowFunctionContext) |
| 56 | , m_canUseOSRExitFuzzing(true) |
ysuzuki@apple.com | cdbe02a | 2019-05-03 18:54:44 +0000 | [diff] [blame] | 57 | , m_codeForGeneratorBodyWasGenerated(false) |
tzagallo@apple.com | 30abe89 | 2020-03-27 18:39:46 +0000 | [diff] [blame] | 58 | , m_isInsideOrdinaryFunction(isInsideOrdinaryFunction) |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 59 | , m_derivedContextType(static_cast<unsigned>(derivedContextType)) |
| 60 | , m_evalContextType(static_cast<unsigned>(evalContextType)) |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 61 | { |
| 62 | } |
| 63 | |
| 64 | void ScriptExecutable::destroy(JSCell* cell) |
| 65 | { |
| 66 | static_cast<ScriptExecutable*>(cell)->ScriptExecutable::~ScriptExecutable(); |
| 67 | } |
| 68 | |
mark.lam@apple.com | 38aca1d | 2018-06-21 15:09:40 +0000 | [diff] [blame] | 69 | void ScriptExecutable::clearCode(IsoCellSet& clearableCodeSet) |
| 70 | { |
ysuzuki@apple.com | 6189a49 | 2019-02-06 19:49:04 +0000 | [diff] [blame] | 71 | m_jitCodeForCall = nullptr; |
| 72 | m_jitCodeForConstruct = nullptr; |
| 73 | m_jitCodeForCallWithArityCheck = MacroAssemblerCodePtr<JSEntryPtrTag>(); |
| 74 | m_jitCodeForConstructWithArityCheck = MacroAssemblerCodePtr<JSEntryPtrTag>(); |
ysuzuki@apple.com | 6189a49 | 2019-02-06 19:49:04 +0000 | [diff] [blame] | 75 | |
| 76 | switch (type()) { |
| 77 | case FunctionExecutableType: { |
| 78 | FunctionExecutable* executable = static_cast<FunctionExecutable*>(this); |
| 79 | executable->m_codeBlockForCall.clear(); |
| 80 | executable->m_codeBlockForConstruct.clear(); |
| 81 | break; |
| 82 | } |
| 83 | case EvalExecutableType: { |
| 84 | EvalExecutable* executable = static_cast<EvalExecutable*>(this); |
| 85 | executable->m_evalCodeBlock.clear(); |
| 86 | executable->m_unlinkedEvalCodeBlock.clear(); |
| 87 | break; |
| 88 | } |
| 89 | case ProgramExecutableType: { |
| 90 | ProgramExecutable* executable = static_cast<ProgramExecutable*>(this); |
| 91 | executable->m_programCodeBlock.clear(); |
| 92 | executable->m_unlinkedProgramCodeBlock.clear(); |
| 93 | break; |
| 94 | } |
| 95 | case ModuleProgramExecutableType: { |
| 96 | ModuleProgramExecutable* executable = static_cast<ModuleProgramExecutable*>(this); |
| 97 | executable->m_moduleProgramCodeBlock.clear(); |
| 98 | executable->m_unlinkedModuleProgramCodeBlock.clear(); |
| 99 | executable->m_moduleEnvironmentSymbolTable.clear(); |
| 100 | break; |
| 101 | } |
| 102 | default: |
| 103 | RELEASE_ASSERT_NOT_REACHED(); |
| 104 | break; |
| 105 | } |
| 106 | |
ysuzuki@apple.com | 64b74db | 2019-02-05 06:32:08 +0000 | [diff] [blame] | 107 | ASSERT(&VM::SpaceAndSet::setFor(*subspace()) == &clearableCodeSet); |
mark.lam@apple.com | 38aca1d | 2018-06-21 15:09:40 +0000 | [diff] [blame] | 108 | clearableCodeSet.remove(this); |
| 109 | } |
| 110 | |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 111 | void ScriptExecutable::installCode(CodeBlock* codeBlock) |
| 112 | { |
mark.lam@apple.com | 5ba0779 | 2019-08-27 22:14:52 +0000 | [diff] [blame] | 113 | installCode(codeBlock->vm(), codeBlock, codeBlock->codeType(), codeBlock->specializationKind()); |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | void ScriptExecutable::installCode(VM& vm, CodeBlock* genericCodeBlock, CodeType codeType, CodeSpecializationKind kind) |
| 117 | { |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 118 | if (genericCodeBlock) |
| 119 | CODEBLOCK_LOG_EVENT(genericCodeBlock, "installCode", ()); |
| 120 | |
| 121 | CodeBlock* oldCodeBlock = nullptr; |
| 122 | |
| 123 | switch (codeType) { |
| 124 | case GlobalCode: { |
| 125 | ProgramExecutable* executable = jsCast<ProgramExecutable*>(this); |
| 126 | ProgramCodeBlock* codeBlock = static_cast<ProgramCodeBlock*>(genericCodeBlock); |
| 127 | |
| 128 | ASSERT(kind == CodeForCall); |
| 129 | |
fpizlo@apple.com | a5a2f0b | 2018-01-11 16:43:07 +0000 | [diff] [blame] | 130 | oldCodeBlock = ExecutableToCodeBlockEdge::deactivateAndUnwrap(executable->m_programCodeBlock.get()); |
| 131 | executable->m_programCodeBlock.setMayBeNull(vm, this, ExecutableToCodeBlockEdge::wrapAndActivate(codeBlock)); |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 132 | break; |
| 133 | } |
| 134 | |
| 135 | case ModuleCode: { |
| 136 | ModuleProgramExecutable* executable = jsCast<ModuleProgramExecutable*>(this); |
| 137 | ModuleProgramCodeBlock* codeBlock = static_cast<ModuleProgramCodeBlock*>(genericCodeBlock); |
| 138 | |
| 139 | ASSERT(kind == CodeForCall); |
| 140 | |
fpizlo@apple.com | a5a2f0b | 2018-01-11 16:43:07 +0000 | [diff] [blame] | 141 | oldCodeBlock = ExecutableToCodeBlockEdge::deactivateAndUnwrap(executable->m_moduleProgramCodeBlock.get()); |
| 142 | executable->m_moduleProgramCodeBlock.setMayBeNull(vm, this, ExecutableToCodeBlockEdge::wrapAndActivate(codeBlock)); |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 143 | break; |
| 144 | } |
| 145 | |
| 146 | case EvalCode: { |
| 147 | EvalExecutable* executable = jsCast<EvalExecutable*>(this); |
| 148 | EvalCodeBlock* codeBlock = static_cast<EvalCodeBlock*>(genericCodeBlock); |
| 149 | |
| 150 | ASSERT(kind == CodeForCall); |
| 151 | |
fpizlo@apple.com | a5a2f0b | 2018-01-11 16:43:07 +0000 | [diff] [blame] | 152 | oldCodeBlock = ExecutableToCodeBlockEdge::deactivateAndUnwrap(executable->m_evalCodeBlock.get()); |
| 153 | executable->m_evalCodeBlock.setMayBeNull(vm, this, ExecutableToCodeBlockEdge::wrapAndActivate(codeBlock)); |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 154 | break; |
| 155 | } |
| 156 | |
| 157 | case FunctionCode: { |
| 158 | FunctionExecutable* executable = jsCast<FunctionExecutable*>(this); |
| 159 | FunctionCodeBlock* codeBlock = static_cast<FunctionCodeBlock*>(genericCodeBlock); |
| 160 | |
| 161 | switch (kind) { |
| 162 | case CodeForCall: |
fpizlo@apple.com | a5a2f0b | 2018-01-11 16:43:07 +0000 | [diff] [blame] | 163 | oldCodeBlock = ExecutableToCodeBlockEdge::deactivateAndUnwrap(executable->m_codeBlockForCall.get()); |
| 164 | executable->m_codeBlockForCall.setMayBeNull(vm, this, ExecutableToCodeBlockEdge::wrapAndActivate(codeBlock)); |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 165 | break; |
| 166 | case CodeForConstruct: |
fpizlo@apple.com | a5a2f0b | 2018-01-11 16:43:07 +0000 | [diff] [blame] | 167 | oldCodeBlock = ExecutableToCodeBlockEdge::deactivateAndUnwrap(executable->m_codeBlockForConstruct.get()); |
| 168 | executable->m_codeBlockForConstruct.setMayBeNull(vm, this, ExecutableToCodeBlockEdge::wrapAndActivate(codeBlock)); |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 169 | break; |
| 170 | } |
| 171 | break; |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | switch (kind) { |
| 176 | case CodeForCall: |
| 177 | m_jitCodeForCall = genericCodeBlock ? genericCodeBlock->jitCode() : nullptr; |
mark.lam@apple.com | de0dba7 | 2018-04-18 03:31:09 +0000 | [diff] [blame] | 178 | m_jitCodeForCallWithArityCheck = nullptr; |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 179 | break; |
| 180 | case CodeForConstruct: |
| 181 | m_jitCodeForConstruct = genericCodeBlock ? genericCodeBlock->jitCode() : nullptr; |
mark.lam@apple.com | de0dba7 | 2018-04-18 03:31:09 +0000 | [diff] [blame] | 182 | m_jitCodeForConstructWithArityCheck = nullptr; |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 183 | break; |
| 184 | } |
| 185 | |
ysuzuki@apple.com | 64b74db | 2019-02-05 06:32:08 +0000 | [diff] [blame] | 186 | auto& clearableCodeSet = VM::SpaceAndSet::setFor(*subspace()); |
ysuzuki@apple.com | 6189a49 | 2019-02-06 19:49:04 +0000 | [diff] [blame] | 187 | if (hasClearableCode(vm)) |
mark.lam@apple.com | 38aca1d | 2018-06-21 15:09:40 +0000 | [diff] [blame] | 188 | clearableCodeSet.add(this); |
| 189 | else |
| 190 | clearableCodeSet.remove(this); |
| 191 | |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 192 | if (genericCodeBlock) { |
| 193 | RELEASE_ASSERT(genericCodeBlock->ownerExecutable() == this); |
| 194 | RELEASE_ASSERT(JITCode::isExecutableScript(genericCodeBlock->jitType())); |
| 195 | |
rmorisset@apple.com | b966ea9 | 2020-01-16 23:24:38 +0000 | [diff] [blame] | 196 | dataLogLnIf(Options::verboseOSR(), "Installing ", *genericCodeBlock); |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 197 | |
mark.lam@apple.com | 167235e | 2017-08-10 23:00:06 +0000 | [diff] [blame] | 198 | if (UNLIKELY(vm.m_perBytecodeProfiler)) |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 199 | vm.m_perBytecodeProfiler->ensureBytecodesFor(genericCodeBlock); |
| 200 | |
mark.lam@apple.com | 167235e | 2017-08-10 23:00:06 +0000 | [diff] [blame] | 201 | Debugger* debugger = genericCodeBlock->globalObject()->debugger(); |
| 202 | if (UNLIKELY(debugger)) |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 203 | debugger->registerCodeBlock(genericCodeBlock); |
| 204 | } |
| 205 | |
| 206 | if (oldCodeBlock) |
| 207 | oldCodeBlock->unlinkIncomingCalls(); |
| 208 | |
| 209 | vm.heap.writeBarrier(this); |
| 210 | } |
| 211 | |
ysuzuki@apple.com | 6189a49 | 2019-02-06 19:49:04 +0000 | [diff] [blame] | 212 | bool ScriptExecutable::hasClearableCode(VM& vm) const |
| 213 | { |
ysuzuki@apple.com | 6189a49 | 2019-02-06 19:49:04 +0000 | [diff] [blame] | 214 | if (m_jitCodeForCall |
| 215 | || m_jitCodeForConstruct |
| 216 | || m_jitCodeForCallWithArityCheck |
| 217 | || m_jitCodeForConstructWithArityCheck) |
| 218 | return true; |
ysuzuki@apple.com | 6189a49 | 2019-02-06 19:49:04 +0000 | [diff] [blame] | 219 | |
| 220 | if (structure(vm)->classInfo() == FunctionExecutable::info()) { |
| 221 | auto* executable = static_cast<const FunctionExecutable*>(this); |
| 222 | if (executable->m_codeBlockForCall || executable->m_codeBlockForConstruct) |
| 223 | return true; |
| 224 | |
| 225 | } else if (structure(vm)->classInfo() == EvalExecutable::info()) { |
| 226 | auto* executable = static_cast<const EvalExecutable*>(this); |
| 227 | if (executable->m_evalCodeBlock || executable->m_unlinkedEvalCodeBlock) |
| 228 | return true; |
| 229 | |
| 230 | } else if (structure(vm)->classInfo() == ProgramExecutable::info()) { |
| 231 | auto* executable = static_cast<const ProgramExecutable*>(this); |
| 232 | if (executable->m_programCodeBlock || executable->m_unlinkedProgramCodeBlock) |
| 233 | return true; |
| 234 | |
| 235 | } else if (structure(vm)->classInfo() == ModuleProgramExecutable::info()) { |
| 236 | auto* executable = static_cast<const ModuleProgramExecutable*>(this); |
| 237 | if (executable->m_moduleProgramCodeBlock |
| 238 | || executable->m_unlinkedModuleProgramCodeBlock |
| 239 | || executable->m_moduleEnvironmentSymbolTable) |
| 240 | return true; |
| 241 | } |
| 242 | return false; |
| 243 | } |
| 244 | |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 245 | CodeBlock* ScriptExecutable::newCodeBlockFor( |
mark.lam@apple.com | 60c090d | 2019-03-07 10:16:58 +0000 | [diff] [blame] | 246 | CodeSpecializationKind kind, JSFunction* function, JSScope* scope, Exception*& exception) |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 247 | { |
mark.lam@apple.com | 5ba0779 | 2019-08-27 22:14:52 +0000 | [diff] [blame] | 248 | VM& vm = scope->vm(); |
| 249 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 250 | |
mark.lam@apple.com | 5ba0779 | 2019-08-27 22:14:52 +0000 | [diff] [blame] | 251 | ASSERT(vm.heap.isDeferred()); |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 252 | ASSERT(endColumn() != UINT_MAX); |
| 253 | |
mark.lam@apple.com | 5ba0779 | 2019-08-27 22:14:52 +0000 | [diff] [blame] | 254 | JSGlobalObject* globalObject = scope->globalObject(vm); |
commit-queue@webkit.org | 2162b03 | 2017-03-10 02:00:33 +0000 | [diff] [blame] | 255 | |
mark.lam@apple.com | 5ba0779 | 2019-08-27 22:14:52 +0000 | [diff] [blame] | 256 | if (classInfo(vm) == EvalExecutable::info()) { |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 257 | EvalExecutable* executable = jsCast<EvalExecutable*>(this); |
| 258 | RELEASE_ASSERT(kind == CodeForCall); |
| 259 | RELEASE_ASSERT(!executable->m_evalCodeBlock); |
| 260 | RELEASE_ASSERT(!function); |
commit-queue@webkit.org | 2162b03 | 2017-03-10 02:00:33 +0000 | [diff] [blame] | 261 | auto codeBlock = EvalCodeBlock::create(vm, |
ysuzuki@apple.com | c9db6aa | 2019-02-09 00:29:21 +0000 | [diff] [blame] | 262 | executable, executable->m_unlinkedEvalCodeBlock.get(), scope); |
mark.lam@apple.com | 135cad5 | 2017-09-11 06:23:39 +0000 | [diff] [blame] | 263 | EXCEPTION_ASSERT(throwScope.exception() || codeBlock); |
commit-queue@webkit.org | 2162b03 | 2017-03-10 02:00:33 +0000 | [diff] [blame] | 264 | if (!codeBlock) { |
| 265 | exception = throwException( |
ysuzuki@apple.com | 52e98bb | 2019-10-22 09:24:48 +0000 | [diff] [blame] | 266 | globalObject, throwScope, |
| 267 | createOutOfMemoryError(globalObject)); |
commit-queue@webkit.org | 2162b03 | 2017-03-10 02:00:33 +0000 | [diff] [blame] | 268 | return nullptr; |
| 269 | } |
| 270 | return codeBlock; |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 271 | } |
| 272 | |
mark.lam@apple.com | 5ba0779 | 2019-08-27 22:14:52 +0000 | [diff] [blame] | 273 | if (classInfo(vm) == ProgramExecutable::info()) { |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 274 | ProgramExecutable* executable = jsCast<ProgramExecutable*>(this); |
| 275 | RELEASE_ASSERT(kind == CodeForCall); |
| 276 | RELEASE_ASSERT(!executable->m_programCodeBlock); |
| 277 | RELEASE_ASSERT(!function); |
commit-queue@webkit.org | 2162b03 | 2017-03-10 02:00:33 +0000 | [diff] [blame] | 278 | auto codeBlock = ProgramCodeBlock::create(vm, |
ysuzuki@apple.com | c9db6aa | 2019-02-09 00:29:21 +0000 | [diff] [blame] | 279 | executable, executable->m_unlinkedProgramCodeBlock.get(), scope); |
mark.lam@apple.com | 135cad5 | 2017-09-11 06:23:39 +0000 | [diff] [blame] | 280 | EXCEPTION_ASSERT(throwScope.exception() || codeBlock); |
commit-queue@webkit.org | 2162b03 | 2017-03-10 02:00:33 +0000 | [diff] [blame] | 281 | if (!codeBlock) { |
| 282 | exception = throwException( |
ysuzuki@apple.com | 52e98bb | 2019-10-22 09:24:48 +0000 | [diff] [blame] | 283 | globalObject, throwScope, |
| 284 | createOutOfMemoryError(globalObject)); |
commit-queue@webkit.org | 2162b03 | 2017-03-10 02:00:33 +0000 | [diff] [blame] | 285 | return nullptr; |
| 286 | } |
| 287 | return codeBlock; |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 288 | } |
| 289 | |
mark.lam@apple.com | 5ba0779 | 2019-08-27 22:14:52 +0000 | [diff] [blame] | 290 | if (classInfo(vm) == ModuleProgramExecutable::info()) { |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 291 | ModuleProgramExecutable* executable = jsCast<ModuleProgramExecutable*>(this); |
| 292 | RELEASE_ASSERT(kind == CodeForCall); |
| 293 | RELEASE_ASSERT(!executable->m_moduleProgramCodeBlock); |
| 294 | RELEASE_ASSERT(!function); |
commit-queue@webkit.org | 2162b03 | 2017-03-10 02:00:33 +0000 | [diff] [blame] | 295 | auto codeBlock = ModuleProgramCodeBlock::create(vm, |
ysuzuki@apple.com | c9db6aa | 2019-02-09 00:29:21 +0000 | [diff] [blame] | 296 | executable, executable->m_unlinkedModuleProgramCodeBlock.get(), scope); |
mark.lam@apple.com | 135cad5 | 2017-09-11 06:23:39 +0000 | [diff] [blame] | 297 | EXCEPTION_ASSERT(throwScope.exception() || codeBlock); |
commit-queue@webkit.org | 2162b03 | 2017-03-10 02:00:33 +0000 | [diff] [blame] | 298 | if (!codeBlock) { |
| 299 | exception = throwException( |
ysuzuki@apple.com | 52e98bb | 2019-10-22 09:24:48 +0000 | [diff] [blame] | 300 | globalObject, throwScope, |
| 301 | createOutOfMemoryError(globalObject)); |
commit-queue@webkit.org | 2162b03 | 2017-03-10 02:00:33 +0000 | [diff] [blame] | 302 | return nullptr; |
| 303 | } |
| 304 | return codeBlock; |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 305 | } |
| 306 | |
mark.lam@apple.com | 5ba0779 | 2019-08-27 22:14:52 +0000 | [diff] [blame] | 307 | RELEASE_ASSERT(classInfo(vm) == FunctionExecutable::info()); |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 308 | RELEASE_ASSERT(function); |
| 309 | FunctionExecutable* executable = jsCast<FunctionExecutable*>(this); |
| 310 | RELEASE_ASSERT(!executable->codeBlockFor(kind)); |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 311 | ParserError error; |
ysuzuki@apple.com | cdbe02a | 2019-05-03 18:54:44 +0000 | [diff] [blame] | 312 | OptionSet<CodeGenerationMode> codeGenerationMode = globalObject->defaultCodeGenerationMode(); |
| 313 | // We continue using the same CodeGenerationMode for Generators because live generator objects can |
| 314 | // keep the state which is only valid with the CodeBlock compiled with the same CodeGenerationMode. |
| 315 | if (isGeneratorOrAsyncFunctionBodyParseMode(executable->parseMode())) { |
| 316 | if (!m_codeForGeneratorBodyWasGenerated) { |
| 317 | m_codeGenerationModeForGeneratorBody = codeGenerationMode; |
| 318 | m_codeForGeneratorBodyWasGenerated = true; |
| 319 | } else |
| 320 | codeGenerationMode = m_codeGenerationModeForGeneratorBody; |
| 321 | } |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 322 | UnlinkedFunctionCodeBlock* unlinkedCodeBlock = |
| 323 | executable->m_unlinkedExecutable->unlinkedCodeBlockFor( |
mark.lam@apple.com | 5ba0779 | 2019-08-27 22:14:52 +0000 | [diff] [blame] | 324 | vm, executable->source(), kind, codeGenerationMode, error, |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 325 | executable->parseMode()); |
| 326 | recordParse( |
| 327 | executable->m_unlinkedExecutable->features(), |
ggaren@apple.com | a5548d5 | 2016-12-05 22:46:06 +0000 | [diff] [blame] | 328 | executable->m_unlinkedExecutable->hasCapturedVariables(), |
| 329 | lastLine(), endColumn()); |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 330 | if (!unlinkedCodeBlock) { |
| 331 | exception = throwException( |
ysuzuki@apple.com | 52e98bb | 2019-10-22 09:24:48 +0000 | [diff] [blame] | 332 | globalObject, throwScope, |
ysuzuki@apple.com | 5ff64dc | 2019-03-22 07:14:43 +0000 | [diff] [blame] | 333 | error.toErrorObject(globalObject, executable->source())); |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 334 | return nullptr; |
| 335 | } |
| 336 | |
ysuzuki@apple.com | c9db6aa | 2019-02-09 00:29:21 +0000 | [diff] [blame] | 337 | RELEASE_AND_RETURN(throwScope, FunctionCodeBlock::create(vm, executable, unlinkedCodeBlock, scope)); |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 338 | } |
| 339 | |
| 340 | CodeBlock* ScriptExecutable::newReplacementCodeBlockFor( |
| 341 | CodeSpecializationKind kind) |
| 342 | { |
mark.lam@apple.com | 5ba0779 | 2019-08-27 22:14:52 +0000 | [diff] [blame] | 343 | VM& vm = this->vm(); |
keith_miller@apple.com | 45da760 | 2017-01-27 01:47:52 +0000 | [diff] [blame] | 344 | if (classInfo(vm) == EvalExecutable::info()) { |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 345 | RELEASE_ASSERT(kind == CodeForCall); |
| 346 | EvalExecutable* executable = jsCast<EvalExecutable*>(this); |
| 347 | EvalCodeBlock* baseline = static_cast<EvalCodeBlock*>( |
fpizlo@apple.com | a5a2f0b | 2018-01-11 16:43:07 +0000 | [diff] [blame] | 348 | executable->codeBlock()->baselineVersion()); |
mark.lam@apple.com | 5ba0779 | 2019-08-27 22:14:52 +0000 | [diff] [blame] | 349 | EvalCodeBlock* result = EvalCodeBlock::create(vm, |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 350 | CodeBlock::CopyParsedBlock, *baseline); |
keith_miller@apple.com | 45da760 | 2017-01-27 01:47:52 +0000 | [diff] [blame] | 351 | result->setAlternative(vm, baseline); |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 352 | return result; |
| 353 | } |
| 354 | |
keith_miller@apple.com | 45da760 | 2017-01-27 01:47:52 +0000 | [diff] [blame] | 355 | if (classInfo(vm) == ProgramExecutable::info()) { |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 356 | RELEASE_ASSERT(kind == CodeForCall); |
| 357 | ProgramExecutable* executable = jsCast<ProgramExecutable*>(this); |
| 358 | ProgramCodeBlock* baseline = static_cast<ProgramCodeBlock*>( |
fpizlo@apple.com | a5a2f0b | 2018-01-11 16:43:07 +0000 | [diff] [blame] | 359 | executable->codeBlock()->baselineVersion()); |
mark.lam@apple.com | 5ba0779 | 2019-08-27 22:14:52 +0000 | [diff] [blame] | 360 | ProgramCodeBlock* result = ProgramCodeBlock::create(vm, |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 361 | CodeBlock::CopyParsedBlock, *baseline); |
keith_miller@apple.com | 45da760 | 2017-01-27 01:47:52 +0000 | [diff] [blame] | 362 | result->setAlternative(vm, baseline); |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 363 | return result; |
| 364 | } |
| 365 | |
keith_miller@apple.com | 45da760 | 2017-01-27 01:47:52 +0000 | [diff] [blame] | 366 | if (classInfo(vm) == ModuleProgramExecutable::info()) { |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 367 | RELEASE_ASSERT(kind == CodeForCall); |
| 368 | ModuleProgramExecutable* executable = jsCast<ModuleProgramExecutable*>(this); |
| 369 | ModuleProgramCodeBlock* baseline = static_cast<ModuleProgramCodeBlock*>( |
fpizlo@apple.com | a5a2f0b | 2018-01-11 16:43:07 +0000 | [diff] [blame] | 370 | executable->codeBlock()->baselineVersion()); |
mark.lam@apple.com | 5ba0779 | 2019-08-27 22:14:52 +0000 | [diff] [blame] | 371 | ModuleProgramCodeBlock* result = ModuleProgramCodeBlock::create(vm, |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 372 | CodeBlock::CopyParsedBlock, *baseline); |
keith_miller@apple.com | 45da760 | 2017-01-27 01:47:52 +0000 | [diff] [blame] | 373 | result->setAlternative(vm, baseline); |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 374 | return result; |
| 375 | } |
| 376 | |
keith_miller@apple.com | 45da760 | 2017-01-27 01:47:52 +0000 | [diff] [blame] | 377 | RELEASE_ASSERT(classInfo(vm) == FunctionExecutable::info()); |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 378 | FunctionExecutable* executable = jsCast<FunctionExecutable*>(this); |
| 379 | FunctionCodeBlock* baseline = static_cast<FunctionCodeBlock*>( |
| 380 | executable->codeBlockFor(kind)->baselineVersion()); |
mark.lam@apple.com | 5ba0779 | 2019-08-27 22:14:52 +0000 | [diff] [blame] | 381 | FunctionCodeBlock* result = FunctionCodeBlock::create(vm, |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 382 | CodeBlock::CopyParsedBlock, *baseline); |
keith_miller@apple.com | 45da760 | 2017-01-27 01:47:52 +0000 | [diff] [blame] | 383 | result->setAlternative(vm, baseline); |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 384 | return result; |
| 385 | } |
| 386 | |
ticaiolima@gmail.com | 49f5dbf | 2019-03-19 13:36:05 +0000 | [diff] [blame] | 387 | static void setupLLInt(CodeBlock* codeBlock) |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 388 | { |
ticaiolima@gmail.com | 49f5dbf | 2019-03-19 13:36:05 +0000 | [diff] [blame] | 389 | LLInt::setEntrypoint(codeBlock); |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 390 | } |
| 391 | |
| 392 | static void setupJIT(VM& vm, CodeBlock* codeBlock) |
| 393 | { |
| 394 | #if ENABLE(JIT) |
mark.lam@apple.com | 5ba0779 | 2019-08-27 22:14:52 +0000 | [diff] [blame] | 395 | CompilationResult result = JIT::compile(vm, codeBlock, JITCompilationMustSucceed); |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 396 | RELEASE_ASSERT(result == CompilationSuccessful); |
| 397 | #else |
| 398 | UNUSED_PARAM(vm); |
| 399 | UNUSED_PARAM(codeBlock); |
| 400 | UNREACHABLE_FOR_PLATFORM(); |
| 401 | #endif |
| 402 | } |
| 403 | |
mark.lam@apple.com | 60c090d | 2019-03-07 10:16:58 +0000 | [diff] [blame] | 404 | Exception* ScriptExecutable::prepareForExecutionImpl( |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 405 | VM& vm, JSFunction* function, JSScope* scope, CodeSpecializationKind kind, CodeBlock*& resultCodeBlock) |
| 406 | { |
mark.lam@apple.com | 758b378 | 2016-11-21 17:19:30 +0000 | [diff] [blame] | 407 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 408 | DeferGCForAWhile deferGC(vm.heap); |
| 409 | |
mark.lam@apple.com | 60c090d | 2019-03-07 10:16:58 +0000 | [diff] [blame] | 410 | if (UNLIKELY(vm.getAndClearFailNextNewCodeBlock())) { |
ysuzuki@apple.com | 52e98bb | 2019-10-22 09:24:48 +0000 | [diff] [blame] | 411 | JSGlobalObject* globalObject = scope->globalObject(vm); |
| 412 | return throwException(globalObject, throwScope, createError(globalObject, "Forced Failure"_s)); |
mark.lam@apple.com | 758b378 | 2016-11-21 17:19:30 +0000 | [diff] [blame] | 413 | } |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 414 | |
mark.lam@apple.com | 60c090d | 2019-03-07 10:16:58 +0000 | [diff] [blame] | 415 | Exception* exception = nullptr; |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 416 | CodeBlock* codeBlock = newCodeBlockFor(kind, function, scope, exception); |
| 417 | resultCodeBlock = codeBlock; |
mark.lam@apple.com | 135cad5 | 2017-09-11 06:23:39 +0000 | [diff] [blame] | 418 | EXCEPTION_ASSERT(!!throwScope.exception() == !codeBlock); |
mark.lam@apple.com | 758b378 | 2016-11-21 17:19:30 +0000 | [diff] [blame] | 419 | if (UNLIKELY(!codeBlock)) |
ryanhaddad@apple.com | bd06387 | 2018-10-12 21:42:23 +0000 | [diff] [blame] | 420 | return exception; |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 421 | |
| 422 | if (Options::validateBytecode()) |
| 423 | codeBlock->validate(); |
| 424 | |
commit-queue@webkit.org | be3c27f | 2020-01-15 06:02:48 +0000 | [diff] [blame] | 425 | if (Options::useLLInt()) |
sbarati@apple.com | a254372 | 2020-01-14 01:43:03 +0000 | [diff] [blame] | 426 | setupLLInt(codeBlock); |
commit-queue@webkit.org | be3c27f | 2020-01-15 06:02:48 +0000 | [diff] [blame] | 427 | else |
| 428 | setupJIT(vm, codeBlock); |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 429 | |
| 430 | installCode(vm, codeBlock, codeBlock->codeType(), codeBlock->specializationKind()); |
ryanhaddad@apple.com | bd06387 | 2018-10-12 21:42:23 +0000 | [diff] [blame] | 431 | return nullptr; |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 432 | } |
| 433 | |
ysuzuki@apple.com | e583634 | 2019-05-07 22:15:59 +0000 | [diff] [blame] | 434 | ScriptExecutable* ScriptExecutable::topLevelExecutable() |
| 435 | { |
| 436 | switch (type()) { |
| 437 | case FunctionExecutableType: |
| 438 | return jsCast<FunctionExecutable*>(this)->topLevelExecutable(); |
| 439 | default: |
| 440 | return this; |
| 441 | } |
| 442 | } |
| 443 | |
ysuzuki@apple.com | 52e98bb | 2019-10-22 09:24:48 +0000 | [diff] [blame] | 444 | JSArray* ScriptExecutable::createTemplateObject(JSGlobalObject* globalObject, JSTemplateObjectDescriptor* descriptor) |
ysuzuki@apple.com | e583634 | 2019-05-07 22:15:59 +0000 | [diff] [blame] | 445 | { |
ysuzuki@apple.com | 52e98bb | 2019-10-22 09:24:48 +0000 | [diff] [blame] | 446 | VM& vm = globalObject->vm(); |
ysuzuki@apple.com | e583634 | 2019-05-07 22:15:59 +0000 | [diff] [blame] | 447 | auto scope = DECLARE_THROW_SCOPE(vm); |
| 448 | |
| 449 | TemplateObjectMap& templateObjectMap = ensureTemplateObjectMap(vm); |
| 450 | TemplateObjectMap::AddResult result; |
| 451 | { |
| 452 | auto locker = holdLock(cellLock()); |
| 453 | result = templateObjectMap.add(descriptor->endOffset(), WriteBarrier<JSArray>()); |
| 454 | } |
| 455 | if (JSArray* array = result.iterator->value.get()) |
| 456 | return array; |
ysuzuki@apple.com | 52e98bb | 2019-10-22 09:24:48 +0000 | [diff] [blame] | 457 | JSArray* templateObject = descriptor->createTemplateObject(globalObject); |
ysuzuki@apple.com | e583634 | 2019-05-07 22:15:59 +0000 | [diff] [blame] | 458 | RETURN_IF_EXCEPTION(scope, nullptr); |
| 459 | result.iterator->value.set(vm, this, templateObject); |
| 460 | return templateObject; |
| 461 | } |
| 462 | |
| 463 | auto ScriptExecutable::ensureTemplateObjectMapImpl(std::unique_ptr<TemplateObjectMap>& dest) -> TemplateObjectMap& |
| 464 | { |
| 465 | if (dest) |
| 466 | return *dest; |
ysuzuki@apple.com | 1d8e24d | 2019-08-19 06:59:40 +0000 | [diff] [blame] | 467 | auto result = makeUnique<TemplateObjectMap>(); |
ysuzuki@apple.com | e583634 | 2019-05-07 22:15:59 +0000 | [diff] [blame] | 468 | WTF::storeStoreFence(); |
| 469 | dest = WTFMove(result); |
| 470 | return *dest; |
| 471 | } |
| 472 | |
| 473 | auto ScriptExecutable::ensureTemplateObjectMap(VM& vm) -> TemplateObjectMap& |
| 474 | { |
| 475 | switch (type()) { |
| 476 | case FunctionExecutableType: |
| 477 | return static_cast<FunctionExecutable*>(this)->ensureTemplateObjectMap(vm); |
| 478 | case EvalExecutableType: |
| 479 | return static_cast<EvalExecutable*>(this)->ensureTemplateObjectMap(vm); |
| 480 | case ProgramExecutableType: |
| 481 | return static_cast<ProgramExecutable*>(this)->ensureTemplateObjectMap(vm); |
| 482 | case ModuleProgramExecutableType: |
| 483 | default: |
| 484 | ASSERT(type() == ModuleProgramExecutableType); |
| 485 | return static_cast<ModuleProgramExecutable*>(this)->ensureTemplateObjectMap(vm); |
| 486 | } |
| 487 | } |
| 488 | |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 489 | CodeBlockHash ScriptExecutable::hashFor(CodeSpecializationKind kind) const |
| 490 | { |
| 491 | return CodeBlockHash(source(), kind); |
| 492 | } |
| 493 | |
ysuzuki@apple.com | 5fbfa40 | 2019-02-04 21:02:27 +0000 | [diff] [blame] | 494 | Optional<int> ScriptExecutable::overrideLineNumber(VM& vm) const |
| 495 | { |
| 496 | if (inherits<FunctionExecutable>(vm)) |
| 497 | return jsCast<const FunctionExecutable*>(this)->overrideLineNumber(); |
| 498 | return WTF::nullopt; |
| 499 | } |
| 500 | |
| 501 | unsigned ScriptExecutable::typeProfilingStartOffset(VM& vm) const |
| 502 | { |
| 503 | if (inherits<FunctionExecutable>(vm)) |
| 504 | return jsCast<const FunctionExecutable*>(this)->typeProfilingStartOffset(vm); |
| 505 | if (inherits<EvalExecutable>(vm)) |
| 506 | return UINT_MAX; |
| 507 | return 0; |
| 508 | } |
| 509 | |
| 510 | unsigned ScriptExecutable::typeProfilingEndOffset(VM& vm) const |
| 511 | { |
| 512 | if (inherits<FunctionExecutable>(vm)) |
| 513 | return jsCast<const FunctionExecutable*>(this)->typeProfilingEndOffset(vm); |
| 514 | if (inherits<EvalExecutable>(vm)) |
| 515 | return UINT_MAX; |
ysuzuki@apple.com | 5ff64dc | 2019-03-22 07:14:43 +0000 | [diff] [blame] | 516 | return source().length() - 1; |
| 517 | } |
| 518 | |
| 519 | void ScriptExecutable::recordParse(CodeFeatures features, bool hasCapturedVariables, int lastLine, unsigned endColumn) |
| 520 | { |
| 521 | switch (type()) { |
| 522 | case FunctionExecutableType: |
| 523 | // Since UnlinkedFunctionExecutable holds the information to calculate lastLine and endColumn, we do not need to remember them in ScriptExecutable's fields. |
| 524 | jsCast<FunctionExecutable*>(this)->recordParse(features, hasCapturedVariables); |
| 525 | return; |
| 526 | default: |
| 527 | jsCast<GlobalExecutable*>(this)->recordParse(features, hasCapturedVariables, lastLine, endColumn); |
| 528 | return; |
| 529 | } |
| 530 | } |
| 531 | |
| 532 | int ScriptExecutable::lastLine() const |
| 533 | { |
| 534 | switch (type()) { |
| 535 | case FunctionExecutableType: |
| 536 | return jsCast<const FunctionExecutable*>(this)->lastLine(); |
| 537 | default: |
| 538 | return jsCast<const GlobalExecutable*>(this)->lastLine(); |
| 539 | } |
| 540 | return 0; |
| 541 | } |
| 542 | |
| 543 | unsigned ScriptExecutable::endColumn() const |
| 544 | { |
| 545 | switch (type()) { |
| 546 | case FunctionExecutableType: |
| 547 | return jsCast<const FunctionExecutable*>(this)->endColumn(); |
| 548 | default: |
| 549 | return jsCast<const GlobalExecutable*>(this)->endColumn(); |
| 550 | } |
| 551 | return 0; |
ysuzuki@apple.com | 5fbfa40 | 2019-02-04 21:02:27 +0000 | [diff] [blame] | 552 | } |
| 553 | |
ggaren@apple.com | c9a6ef4 | 2016-10-28 20:04:56 +0000 | [diff] [blame] | 554 | } // namespace JSC |