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

Side by Side Diff: tools/parser-shell.cc

Issue 345513003: Revert "Parser: Delay internalizing strings and values." (r21841) (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/gyp/v8.gyp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 26 matching lines...) Expand all
37 #include "src/compiler.h" 37 #include "src/compiler.h"
38 #include "src/scanner-character-streams.h" 38 #include "src/scanner-character-streams.h"
39 #include "tools/shell-utils.h" 39 #include "tools/shell-utils.h"
40 #include "src/parser.h" 40 #include "src/parser.h"
41 #include "src/preparse-data-format.h" 41 #include "src/preparse-data-format.h"
42 #include "src/preparse-data.h" 42 #include "src/preparse-data.h"
43 #include "src/preparser.h" 43 #include "src/preparser.h"
44 44
45 using namespace v8::internal; 45 using namespace v8::internal;
46 46
47 class StringResource8 : public v8::String::ExternalAsciiStringResource {
48 public:
49 StringResource8(const char* data, int length)
50 : data_(data), length_(length) { }
51 virtual size_t length() const { return length_; }
52 virtual const char* data() const { return data_; }
53
54 private:
55 const char* data_;
56 int length_;
57 };
58
59 std::pair<TimeDelta, TimeDelta> RunBaselineParser( 47 std::pair<TimeDelta, TimeDelta> RunBaselineParser(
60 const char* fname, Encoding encoding, int repeat, v8::Isolate* isolate, 48 const char* fname, Encoding encoding, int repeat, v8::Isolate* isolate,
61 v8::Handle<v8::Context> context) { 49 v8::Handle<v8::Context> context) {
62 int length = 0; 50 int length = 0;
63 const byte* source = ReadFileAndRepeat(fname, &length, repeat); 51 const byte* source = ReadFileAndRepeat(fname, &length, repeat);
64 v8::Handle<v8::String> source_handle; 52 v8::Handle<v8::String> source_handle;
65 switch (encoding) { 53 switch (encoding) {
66 case UTF8: { 54 case UTF8: {
67 source_handle = v8::String::NewFromUtf8( 55 source_handle = v8::String::NewFromUtf8(
68 isolate, reinterpret_cast<const char*>(source)); 56 isolate, reinterpret_cast<const char*>(source));
69 break; 57 break;
70 } 58 }
71 case UTF16: { 59 case UTF16: {
72 source_handle = v8::String::NewFromTwoByte( 60 source_handle = v8::String::NewFromTwoByte(
73 isolate, reinterpret_cast<const uint16_t*>(source), 61 isolate, reinterpret_cast<const uint16_t*>(source),
74 v8::String::kNormalString, length / 2); 62 v8::String::kNormalString, length / 2);
75 break; 63 break;
76 } 64 }
77 case LATIN1: { 65 case LATIN1: {
78 StringResource8* string_resource = 66 source_handle = v8::String::NewFromOneByte(isolate, source);
79 new StringResource8(reinterpret_cast<const char*>(source), length);
80 source_handle = v8::String::NewExternal(isolate, string_resource);
81 break; 67 break;
82 } 68 }
83 } 69 }
84 TimeDelta parse_time1, parse_time2; 70 TimeDelta parse_time1, parse_time2;
85 Handle<Script> script = Isolate::Current()->factory()->NewScript( 71 Handle<Script> script = Isolate::Current()->factory()->NewScript(
86 v8::Utils::OpenHandle(*source_handle)); 72 v8::Utils::OpenHandle(*source_handle));
87 i::ScriptData* cached_data_impl = NULL; 73 i::ScriptData* cached_data_impl = NULL;
88 // First round of parsing (produce data to cache). 74 // First round of parsing (produce data to cache).
89 { 75 {
90 CompilationInfoWithZone info(script); 76 CompilationInfoWithZone info(script);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 if (benchmark.empty()) benchmark = "Baseline"; 148 if (benchmark.empty()) benchmark = "Baseline";
163 printf("%s(FirstParseRunTime): %.f ms\n", benchmark.c_str(), 149 printf("%s(FirstParseRunTime): %.f ms\n", benchmark.c_str(),
164 first_parse_total); 150 first_parse_total);
165 printf("%s(SecondParseRunTime): %.f ms\n", benchmark.c_str(), 151 printf("%s(SecondParseRunTime): %.f ms\n", benchmark.c_str(),
166 second_parse_total); 152 second_parse_total);
167 } 153 }
168 } 154 }
169 v8::V8::Dispose(); 155 v8::V8::Dispose();
170 return 0; 156 return 0;
171 } 157 }
OLDNEW
« no previous file with comments | « tools/gyp/v8.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698