Reviewers: marja,

Message:
PTAL

Description:
Use utf8 instead of ascii in baseline scanner.

BUG=

Please review this at https://chromiumcodereview.appspot.com/26906008/

SVN Base: https://v8.googlecode.com/svn/branches/experimental/parser

Affected files (+15, -15 lines):
  M src/lexer/lexer-shell.cc


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_;
 };




--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to