Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(419)

Side by Side Diff: src/parser.h

Issue 724053004: Revert "Soft fail for invalid cache data." (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler.cc ('k') | src/parser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_PARSER_H_ 5 #ifndef V8_PARSER_H_
6 #define V8_PARSER_H_ 6 #define V8_PARSER_H_
7 7
8 #include "src/allocation.h" 8 #include "src/allocation.h"
9 #include "src/ast.h" 9 #include "src/ast.h"
10 #include "src/compiler.h" // For CachedDataMode 10 #include "src/compiler.h" // For CachedDataMode
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 bool is_valid() { return !backing_.is_empty(); } 55 bool is_valid() { return !backing_.is_empty(); }
56 56
57 private: 57 private:
58 Vector<unsigned> backing_; 58 Vector<unsigned> backing_;
59 }; 59 };
60 60
61 61
62 // Wrapper around ScriptData to provide parser-specific functionality. 62 // Wrapper around ScriptData to provide parser-specific functionality.
63 class ParseData { 63 class ParseData {
64 public: 64 public:
65 static ParseData* FromCachedData(ScriptData* cached_data) { 65 explicit ParseData(ScriptData* script_data) : script_data_(script_data) {
66 ParseData* pd = new ParseData(cached_data); 66 CHECK(IsAligned(script_data->length(), sizeof(unsigned)));
67 if (pd->IsSane()) return pd; 67 CHECK(IsSane());
68 cached_data->Reject();
69 delete pd;
70 return NULL;
71 } 68 }
72
73 void Initialize(); 69 void Initialize();
74 FunctionEntry GetFunctionEntry(int start); 70 FunctionEntry GetFunctionEntry(int start);
75 int FunctionCount(); 71 int FunctionCount();
76 72
77 bool HasError(); 73 bool HasError();
78 74
79 unsigned* Data() { // Writable data as unsigned int array. 75 unsigned* Data() { // Writable data as unsigned int array.
80 return reinterpret_cast<unsigned*>(const_cast<byte*>(script_data_->data())); 76 return reinterpret_cast<unsigned*>(const_cast<byte*>(script_data_->data()));
81 } 77 }
82 78
83 private: 79 private:
84 explicit ParseData(ScriptData* script_data) : script_data_(script_data) {}
85
86 bool IsSane(); 80 bool IsSane();
87 unsigned Magic(); 81 unsigned Magic();
88 unsigned Version(); 82 unsigned Version();
89 int FunctionsSize(); 83 int FunctionsSize();
90 int Length() const { 84 int Length() const {
91 // Script data length is already checked to be a multiple of unsigned size. 85 // Script data length is already checked to be a multiple of unsigned size.
92 return script_data_->length() / sizeof(unsigned); 86 return script_data_->length() / sizeof(unsigned);
93 } 87 }
94 88
95 ScriptData* script_data_; 89 ScriptData* script_data_;
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 // Called by ParseProgram after setting up the scanner. 681 // Called by ParseProgram after setting up the scanner.
688 FunctionLiteral* DoParseProgram(CompilationInfo* info, Scope** scope, 682 FunctionLiteral* DoParseProgram(CompilationInfo* info, Scope** scope,
689 Scope** ad_hoc_eval_scope); 683 Scope** ad_hoc_eval_scope);
690 684
691 void SetCachedData(); 685 void SetCachedData();
692 686
693 bool inside_with() const { return scope_->inside_with(); } 687 bool inside_with() const { return scope_->inside_with(); }
694 ScriptCompiler::CompileOptions compile_options() const { 688 ScriptCompiler::CompileOptions compile_options() const {
695 return info_->compile_options(); 689 return info_->compile_options();
696 } 690 }
697 bool consume_cached_parse_data() const {
698 return compile_options() == ScriptCompiler::kConsumeParserCache &&
699 cached_parse_data_ != NULL;
700 }
701 bool produce_cached_parse_data() const {
702 return compile_options() == ScriptCompiler::kProduceParserCache;
703 }
704 Scope* DeclarationScope(VariableMode mode) { 691 Scope* DeclarationScope(VariableMode mode) {
705 return IsLexicalVariableMode(mode) 692 return IsLexicalVariableMode(mode)
706 ? scope_ : scope_->DeclarationScope(); 693 ? scope_ : scope_->DeclarationScope();
707 } 694 }
708 695
709 // All ParseXXX functions take as the last argument an *ok parameter 696 // All ParseXXX functions take as the last argument an *ok parameter
710 // which is set to false if parsing failed; it is unchanged otherwise. 697 // which is set to false if parsing failed; it is unchanged otherwise.
711 // By making the 'exception handling' explicit, we are forced to check 698 // By making the 'exception handling' explicit, we are forced to check
712 // for failure at the call sites. 699 // for failure at the call sites.
713 void* ParseSourceElements(ZoneList<Statement*>* processor, int end_token, 700 void* ParseSourceElements(ZoneList<Statement*>* processor, int end_token,
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 private: 922 private:
936 static const int kLiteralTypeSlot = 0; 923 static const int kLiteralTypeSlot = 0;
937 static const int kElementsSlot = 1; 924 static const int kElementsSlot = 1;
938 925
939 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); 926 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue);
940 }; 927 };
941 928
942 } } // namespace v8::internal 929 } } // namespace v8::internal
943 930
944 #endif // V8_PARSER_H_ 931 #endif // V8_PARSER_H_
OLDNEW
« no previous file with comments | « src/compiler.cc ('k') | src/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698