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

Unified Diff: preparser/preparser-process.cc

Issue 5593004: Changed interface to preparser to not require pushback support. (Closed)
Patch Set: Created 10 years 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
Index: preparser/preparser-process.cc
diff --git a/preparser/preparser-process.cc b/preparser/preparser-process.cc
index 80e83508e422901c4e0e82878a97dde75fc4775d..63f4835e094160adb044991e93d325878127d4c8 100644
--- a/preparser/preparser-process.cc
+++ b/preparser/preparser-process.cc
@@ -127,7 +127,7 @@ uint32_t ReadUInt32(FILE* source, bool* ok) {
bool ReadBuffer(FILE* source, void* buffer, size_t length) {
- size_t actually_read = fread(buffer, 1, length, stdin);
+ size_t actually_read = fread(buffer, 1, length, source);
return (actually_read == length);
}
@@ -151,21 +151,24 @@ class ScopedPointer {
// Preparse stdin and output result on stdout.
Rico 2010/12/08 09:46:25 I guess the comment is a bit wrong now, input does
Lasse Reichstein 2010/12/08 10:05:36 Good catch. Fixed.
-int PreParseIO() {
+int PreParseIO(FILE* input) {
fprintf(stderr, "LOG: Enter parsing loop\n");
bool ok = true;
- uint32_t length = ReadUInt32(stdin, &ok);
+ uint32_t length = ReadUInt32(input, &ok);
+ fprintf(stderr, "LOG: Input length: %d\n", length);
if (!ok) return kErrorReading;
ScopedPointer<uint8_t> buffer(new uint8_t[length]);
- if (!ReadBuffer(stdin, *buffer, length)) {
+ if (!ReadBuffer(input, *buffer, length)) {
return kErrorReading;
}
UTF8InputStream input_buffer(*buffer, static_cast<size_t>(length));
v8::PreParserData data =
- v8::Preparse(&input_buffer, 64 * sizeof(void*)); // NOLINT
+ v8::Preparse(&input_buffer, 64 * 1024 * sizeof(void*)); // NOLINT
if (data.stack_overflow()) {
+ fprintf(stderr, "LOG: Stack overflow\n");
+ fflush(stderr);
// Report stack overflow error/no-preparser-data.
WriteUInt32(stdout, 0, &ok);
if (!ok) return kErrorWriting;
@@ -173,6 +176,8 @@ int PreParseIO() {
}
uint32_t size = data.size();
+ fprintf(stderr, "LOG: Success, data size: %u\n", size);
+ fflush(stderr);
WriteUInt32(stdout, size, &ok);
if (!ok) return kErrorWriting;
if (!WriteBuffer(stdout, data.data(), size)) {
@@ -185,10 +190,17 @@ int PreParseIO() {
int main(int argc, char* argv[]) {
+ FILE* input = stdin;
+ if (argc > 1) {
+ char* arg = argv[1];
+ FILE* file = fopen(arg, "rb");
+ if (!file) return EXIT_FAILURE;
Rico 2010/12/08 09:46:25 Wy do we do this check that the file exists and ca
Lasse Reichstein 2010/12/08 10:05:36 We check the returns of reads and writes as well.
+ }
int status = 0;
do {
- status = v8::internal::PreParseIO();
+ status = v8::internal::PreParseIO(input);
} while (status == 0);
fprintf(stderr, "EXIT: Failure %d\n", status);
+ fflush(stderr);
return EXIT_FAILURE;
}
« no previous file with comments | « include/v8-preparser.h ('k') | src/preparser-api.cc » ('j') | src/preparser-api.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698