Changeset 167964 in webkit for trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp
- Timestamp:
- Apr 29, 2014, 3:23:17 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp
r167813 r167964 52 52 static UnlinkedFunctionCodeBlock* generateFunctionCodeBlock(VM& vm, UnlinkedFunctionExecutable* executable, const SourceCode& source, CodeSpecializationKind kind, DebuggerMode debuggerMode, ProfilerMode profilerMode, UnlinkedFunctionKind functionKind, ParserError& error) 53 53 { 54 RefPtr<FunctionBodyNode> body = parse<FunctionBodyNode>(&vm, source, executable->parameters(), executable->name(), executable->toStrictness(), JSParseFunctionCode, error); 54 RefPtr<FunctionParameters> parameters = executable->parameters(&vm); 55 if (!parameters) { 56 error = ParserError(ParserError::StackOverflow); 57 error.m_line = source.firstLine(); 58 return 0; 59 } 60 61 RefPtr<FunctionBodyNode> body = parse<FunctionBodyNode>(&vm, source, parameters.get(), executable->name(), executable->toStrictness(), JSParseFunctionCode, error); 55 62 56 63 if (!body) { … … 61 68 if (executable->forceUsesArguments()) 62 69 body->setUsesArguments(); 63 body->finishParsing( executable->parameters(), executable->name(), executable->functionMode());70 body->finishParsing(parameters.get(), executable->name(), executable->functionMode()); 64 71 executable->recordParse(body->features(), body->hasCapturedVariables()); 65 72 … … 93 100 , m_name(node->ident()) 94 101 , m_inferredName(node->inferredName()) 95 , m_parameter s(node->parameters())102 , m_parameterCount(node->parameterCount()) 96 103 , m_firstLineOffset(node->firstLine() - source.firstLine()) 97 104 , m_lineCount(node->lastLine() - node->firstLine()) … … 104 111 , m_functionMode(node->functionMode()) 105 112 { 106 }107 108 size_t UnlinkedFunctionExecutable::parameterCount() const109 {110 return m_parameters->size();111 113 } 112 114 … … 123 125 visitor.append(&thisObject->m_symbolTableForCall); 124 126 visitor.append(&thisObject->m_symbolTableForConstruct); 127 visitor.append(&thisObject->m_parameterString); 125 128 } 126 129 … … 185 188 } 186 189 190 void UnlinkedFunctionExecutable::finishCreation(VM& vm, const SourceCode& source, FunctionBodyNode* node) 191 { 192 Base::finishCreation(vm); 193 m_nameValue.set(vm, this, jsString(&vm, name().string())); 194 // We make an isolated copy of the parameter string as we don't want to keep the 195 // full source string alive. 196 String parameterString = source.provider()->getRange(node->parametersStartOffset(), node->parametersEndOffset()).isolatedCopy(); 197 m_parameterString.set(vm, this, jsString(&vm, parameterString)); 198 } 199 187 200 String UnlinkedFunctionExecutable::paramString() const 188 201 { 189 FunctionParameters& parameters = *m_parameters; 190 StringBuilder builder; 191 for (size_t pos = 0; pos < parameters.size(); ++pos) { 192 if (!builder.isEmpty()) 193 builder.appendLiteral(", "); 194 parameters.at(pos)->toString(builder); 195 } 196 return builder.toString(); 202 return m_parameterString->tryGetValue(); 203 } 204 205 RefPtr<FunctionParameters> UnlinkedFunctionExecutable::parameters(VM* vm) 206 { 207 if (!m_parameterCount) 208 return FunctionParameters::create(nullptr); 209 210 SourceCode parameterSource = makeSource(m_parameterString->tryGetValue()); 211 RefPtr<FunctionParameters> parameters = parseParameters(vm, parameterSource, toStrictness()); 212 ASSERT(!parameters || parameters->size() == m_parameterCount); 213 return parameters; 197 214 } 198 215
Note:
See TracChangeset
for help on using the changeset viewer.