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

Unified Diff: src/lexer/lexer-shell.cc

Issue 26906008: Use utf8 instead of ascii in baseline scanner. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 7 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/lexer/lexer-shell.cc
diff --git a/src/lexer/lexer-shell.cc b/src/lexer/lexer-shell.cc
index bdf8ac0540685f0e0c9d5edd94022507252bd2c7..b65c71141b067b8a20e44a80d7005b154962f229 100644
--- a/src/lexer/lexer-shell.cc
+++ b/src/lexer/lexer-shell.cc
@@ -46,36 +46,34 @@
using namespace v8::internal;
-Handle<String> ReadFile(const char* name, Isolate* isolate) {
+const byte* ReadFile(const char* name, Isolate* isolate, int* size) {
FILE* file = fopen(name, "rb");
- if (file == NULL) return Handle<String>();
+ *size = 0;
+ if (file == NULL) return NULL;
fseek(file, 0, SEEK_END);
- int size = ftell(file);
+ *size = ftell(file);
rewind(file);
- uint8_t* chars = new uint8_t[size + 1];
- chars[size] = '\0';
- for (int i = 0; i < size;) {
- int read = static_cast<int>(fread(&chars[i], 1, size - i, file));
+ byte* chars = new byte[*size + 1];
+ chars[*size] = 0;
+ for (int i = 0; i < *size;) {
+ int read = static_cast<int>(fread(&chars[i], 1, *size - i, file));
i += read;
}
fclose(file);
- Handle<String> result = isolate->factory()->NewStringFromOneByte(
- Vector<const uint8_t>(chars, size));
- delete[] chars;
- return result;
+ return chars;
}
class BaselineScanner {
public:
BaselineScanner(const char* fname, Isolate* isolate) {
- Handle<String> source = ReadFile(fname, isolate);
+ int length = 0;
+ source_ = ReadFile(fname, isolate, &length);
unicode_cache_ = new UnicodeCache();
scanner_ = new Scanner(unicode_cache_);
- stream_ = new GenericStringUtf16CharacterStream(
- source, 0, source->length());
+ stream_ = new Utf8ToUtf16CharacterStream(source_, length);
scanner_->Initialize(stream_);
}
@@ -83,6 +81,7 @@ class BaselineScanner {
delete scanner_;
delete stream_;
delete unicode_cache_;
+ delete source_;
}
Token::Value Next(int* beg_pos, int* end_pos) {
@@ -95,7 +94,8 @@ class BaselineScanner {
private:
UnicodeCache* unicode_cache_;
Scanner* scanner_;
- GenericStringUtf16CharacterStream* stream_;
+ const byte* source_;
+ Utf8ToUtf16CharacterStream* stream_;
};
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698