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

Unified Diff: preparser/preparser-process.cc

Issue 5593004: Changed interface to preparser to not require pushback support. (Closed)
Patch Set: Address review comments. 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
« no previous file with comments | « include/v8-preparser.h ('k') | src/preparser-api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: preparser/preparser-process.cc
diff --git a/preparser/preparser-process.cc b/preparser/preparser-process.cc
index 80e83508e422901c4e0e82878a97dde75fc4775d..3a83a0a852fa19ceb8be78b553f6ea6912aad06f 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);
}
@@ -150,22 +150,25 @@ class ScopedPointer {
};
-// Preparse stdin and output result on stdout.
-int PreParseIO() {
+// Preparse input and output result on stdout.
+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;
+ }
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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698