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

Unified Diff: src/parser.cc

Issue 225753004: Remove the PreCompile API and ScriptData. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
« src/parser.h ('K') | « src/parser.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index d0e01fc371521e28b744cae920a07387912aa3f0..cdf4c5fcc27a4cc9ea6367f5b15fa130c91474a4 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -224,6 +224,34 @@ Handle<String> Parser::LookupCachedSymbol(int symbol_id) {
}
+ScriptDataImpl::ScriptDataImpl(const char* data, int length)
+ : owns_store_(false) {
+ // The length is obviously invalid.
+ if (length % sizeof(unsigned) != 0) {
Sven Panne 2014/04/07 12:44:44 Why do we silently return here? Wouldn't an ASSERT
marja 2014/04/09 12:53:55 This data is coming in via the API, maybe the orig
Sven Panne 2014/04/11 08:18:22 I think that silently (not) doing something is qui
+ return;
+ }
+
+ // Copy the data to ensure it is properly aligned.
Sven Panne 2014/04/07 12:44:44 This comment doesn't really belong here.
marja 2014/04/09 12:53:55 Done.
+ int deserialized_data_length = length / sizeof(unsigned);
+ // If aligned, don't create a copy of the data.
+ if (reinterpret_cast<intptr_t>(data) % sizeof(unsigned) == 0) {
Sven Panne 2014/04/07 12:44:44 I think restructuring this function makes things c
marja 2014/04/09 12:53:55 Done.
+ store_ =
+ Vector<unsigned>(reinterpret_cast<unsigned*>(const_cast<char*>(data)),
+ length / static_cast<int>(sizeof(unsigned)));
+ return;
+ }
+
+ // Copy the data to align it.
+ unsigned* deserialized_data = i::NewArray<unsigned>(deserialized_data_length);
+ i::CopyBytes(reinterpret_cast<char*>(deserialized_data),
+ data, static_cast<size_t>(length));
+
+ // ScriptDataImpl will own the buffer.
+ store_ = i::Vector<unsigned>(deserialized_data, deserialized_data_length);
+ owns_store_ = true;
+}
+
+
FunctionEntry ScriptDataImpl::GetFunctionEntry(int start) {
// The current pre-data entry must be a FunctionEntry with the given
// start position.
@@ -4600,33 +4628,6 @@ int ScriptDataImpl::ReadNumber(byte** source) {
}
-// Create a Scanner for the preparser to use as input, and preparse the source.
-ScriptDataImpl* PreParserApi::PreParse(Isolate* isolate,
- Utf16CharacterStream* source) {
- CompleteParserRecorder recorder;
- HistogramTimerScope timer(isolate->counters()->pre_parse());
- Scanner scanner(isolate->unicode_cache());
- intptr_t stack_limit = isolate->stack_guard()->real_climit();
- PreParser preparser(&scanner, &recorder, stack_limit);
- preparser.set_allow_lazy(true);
- preparser.set_allow_generators(FLAG_harmony_generators);
- preparser.set_allow_for_of(FLAG_harmony_iteration);
- preparser.set_allow_harmony_scoping(FLAG_harmony_scoping);
- preparser.set_allow_harmony_numeric_literals(FLAG_harmony_numeric_literals);
- scanner.Initialize(source);
- PreParser::PreParseResult result = preparser.PreParseProgram();
- if (result == PreParser::kPreParseStackOverflow) {
- isolate->StackOverflow();
- return NULL;
- }
-
- // Extract the accumulated data from the recorder as a single
- // contiguous vector that we are responsible for disposing.
- Vector<unsigned> store = recorder.ExtractData();
- return new ScriptDataImpl(store);
-}
-
-
bool RegExpParser::ParseRegExp(FlatStringReader* input,
bool multiline,
RegExpCompileData* result,
« src/parser.h ('K') | « src/parser.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698