diff options
Diffstat (limited to 'deps/v8/src/parser.cc')
-rw-r--r-- | deps/v8/src/parser.cc | 48 |
1 files changed, 34 insertions, 14 deletions
diff --git a/deps/v8/src/parser.cc b/deps/v8/src/parser.cc index 5353a63460..249c9ced35 100644 --- a/deps/v8/src/parser.cc +++ b/deps/v8/src/parser.cc @@ -764,8 +764,6 @@ FunctionLiteral* Parser::ParseLazy(Handle<SharedFunctionInfo> info, RelocInfo::kNoPosition, type, &ok); // Make sure the results agree. ASSERT(ok == (result != NULL)); - // The only errors should be stack overflows. - ASSERT(ok || stack_overflow_); } // Make sure the target stack is empty. @@ -774,8 +772,8 @@ FunctionLiteral* Parser::ParseLazy(Handle<SharedFunctionInfo> info, // If there was a stack overflow we have to get rid of AST and it is // not safe to do before scope has been deleted. if (result == NULL) { - Top::StackOverflow(); zone_scope->DeleteOnExit(); + if (stack_overflow_) Top::StackOverflow(); } else { Handle<String> inferred_name(info->inferred_name()); result->set_inferred_name(inferred_name); @@ -2523,6 +2521,16 @@ Expression* Parser::ParseUnaryExpression(bool* ok) { } } + // "delete identifier" is a syntax error in strict mode. + if (op == Token::DELETE && temp_scope_->StrictMode()) { + VariableProxy* operand = expression->AsVariableProxy(); + if (operand != NULL && !operand->is_this()) { + ReportMessage("strict_delete", Vector<const char*>::empty()); + *ok = false; + return NULL; + } + } + return new UnaryOperation(op, expression); } else if (Token::IsCountOp(op)) { @@ -3501,6 +3509,12 @@ FunctionLiteral* Parser::ParseFunctionLiteral(Handle<String> var_name, Variable* parameter = top_scope_->DeclareLocal(param_name, Variable::VAR); top_scope_->AddParameter(parameter); num_parameters++; + if (num_parameters > kMaxNumFunctionParameters) { + ReportMessageAt(scanner().location(), "too_many_parameters", + Vector<const char*>::empty()); + *ok = false; + return NULL; + } done = (peek() == Token::RPAREN); if (!done) Expect(Token::COMMA, CHECK_OK); } @@ -3919,16 +3933,15 @@ Expression* Parser::NewThrowError(Handle<String> constructor, Handle<String> type, Vector< Handle<Object> > arguments) { int argc = arguments.length(); - Handle<JSArray> array = Factory::NewJSArray(argc, TENURED); - ASSERT(array->IsJSArray() && array->HasFastElements()); + Handle<FixedArray> elements = Factory::NewFixedArray(argc, TENURED); for (int i = 0; i < argc; i++) { Handle<Object> element = arguments[i]; if (!element.is_null()) { - // We know this doesn't cause a GC here because we allocated the JSArray - // large enough. - array->SetFastElement(i, *element)->ToObjectUnchecked(); + elements->set(i, *element); } } + Handle<JSArray> array = Factory::NewJSArrayWithElements(elements, TENURED); + ZoneList<Expression*>* args = new ZoneList<Expression*>(2); args->Add(new Literal(type)); args->Add(new Literal(array)); @@ -4058,6 +4071,11 @@ Handle<Object> JsonParser::ParseJsonObject() { uint32_t index; if (key->AsArrayIndex(&index)) { SetOwnElement(json_object, index, value); + } else if (key->Equals(Heap::Proto_symbol())) { + // We can't remove the __proto__ accessor since it's hardcoded + // in several places. Instead go along and add the value as + // the prototype of the created object if possible. + SetPrototype(json_object, value); } else { SetLocalPropertyIgnoreAttributes(json_object, key, value, NONE); } @@ -4255,6 +4273,8 @@ RegExpTree* RegExpParser::ParseDisjunction() { capture_index); } builder->AddAtom(body); + // For compatability with JSC and ES3, we allow quantifiers after + // lookaheads, and break in all cases. break; } case '|': { @@ -4328,7 +4348,7 @@ RegExpTree* RegExpParser::ParseDisjunction() { type, captures_started()); builder = stored_state->builder(); - break; + continue; } case '[': { RegExpTree* atom = ParseCharacterClass(CHECK_FAILED); @@ -4351,11 +4371,11 @@ RegExpTree* RegExpParser::ParseDisjunction() { builder->AddAssertion( new RegExpAssertion(RegExpAssertion::NON_BOUNDARY)); continue; - // AtomEscape :: - // CharacterClassEscape - // - // CharacterClassEscape :: one of - // d D s S w W + // AtomEscape :: + // CharacterClassEscape + // + // CharacterClassEscape :: one of + // d D s S w W case 'd': case 'D': case 's': case 'S': case 'w': case 'W': { uc32 c = Next(); Advance(2); |