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

Side by Side Diff: src/parser.h

Issue 3416010: Make preparsing data reusable. (Closed)
Patch Set: Created 10 years, 3 months 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 | « no previous file | src/parser.cc » ('j') | src/parser.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 static const int kPropertyCountOffset = 3; 94 static const int kPropertyCountOffset = 3;
95 static const int kPredataFunctionSkipOffset = 4; 95 static const int kPredataFunctionSkipOffset = 4;
96 static const int kPredataSymbolSkipOffset = 5; 96 static const int kPredataSymbolSkipOffset = 5;
97 }; 97 };
98 98
99 99
100 class ScriptDataImpl : public ScriptData { 100 class ScriptDataImpl : public ScriptData {
101 public: 101 public:
102 explicit ScriptDataImpl(Vector<unsigned> store) 102 explicit ScriptDataImpl(Vector<unsigned> store)
103 : store_(store), 103 : store_(store),
104 function_index_(kHeaderSize), 104 owns_store_(true) { }
105 owns_store_(true) {
106 Initialize();
107 }
108 105
109 // Create an empty ScriptDataImpl that is guaranteed to not satisfy 106 // Create an empty ScriptDataImpl that is guaranteed to not satisfy
110 // a SanityCheck. 107 // a SanityCheck.
111 ScriptDataImpl() : store_(Vector<unsigned>()), owns_store_(false) { } 108 ScriptDataImpl() : store_(Vector<unsigned>()), owns_store_(false) { }
112 109
113 virtual ~ScriptDataImpl(); 110 virtual ~ScriptDataImpl();
114 virtual int Length(); 111 virtual int Length();
115 virtual const char* Data(); 112 virtual const char* Data();
116 virtual bool HasError(); 113 virtual bool HasError();
117 114
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 bool owns_store_; 180 bool owns_store_;
184 181
185 unsigned Read(int position); 182 unsigned Read(int position);
186 unsigned* ReadAddress(int position); 183 unsigned* ReadAddress(int position);
187 // Reads a number from the current symbols 184 // Reads a number from the current symbols
188 int ReadNumber(byte** source); 185 int ReadNumber(byte** source);
189 186
190 ScriptDataImpl(const char* backing_store, int length) 187 ScriptDataImpl(const char* backing_store, int length)
191 : store_(reinterpret_cast<unsigned*>(const_cast<char*>(backing_store)), 188 : store_(reinterpret_cast<unsigned*>(const_cast<char*>(backing_store)),
192 length / sizeof(unsigned)), 189 length / sizeof(unsigned)),
193 function_index_(kHeaderSize),
194 owns_store_(false) { 190 owns_store_(false) {
195 ASSERT_EQ(0, reinterpret_cast<intptr_t>(backing_store) % sizeof(unsigned)); 191 ASSERT_EQ(0, reinterpret_cast<intptr_t>(backing_store) % sizeof(unsigned));
196 Initialize();
197 } 192 }
198 193
199 // Read strings written by ParserRecorder::WriteString. 194 // Read strings written by ParserRecorder::WriteString.
200 static const char* ReadString(unsigned* start, int* chars); 195 static const char* ReadString(unsigned* start, int* chars);
201 196
202 friend class ScriptData; 197 friend class ScriptData;
203 }; 198 };
204 199
205 200
206 // The parser: Takes a script and and context information, and builds a 201 // The parser: Takes a script and and context information, and builds a
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 static const int kTypeSlot = 0; 267 static const int kTypeSlot = 0;
273 static const int kElementsSlot = 1; 268 static const int kElementsSlot = 1;
274 269
275 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); 270 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue);
276 }; 271 };
277 272
278 273
279 } } // namespace v8::internal 274 } } // namespace v8::internal
280 275
281 #endif // V8_PARSER_H_ 276 #endif // V8_PARSER_H_
OLDNEW
« no previous file with comments | « no previous file | src/parser.cc » ('j') | src/parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698