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

Side by Side Diff: src/api.cc

Issue 5545006: Optimized scanner to avoid virtual calls for every character read. (Closed)
Patch Set: Addressed 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/checks.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 1147 matching lines...) Expand 10 before | Expand all | Expand 10 after
1158 EnsureConstructor(this); 1158 EnsureConstructor(this);
1159 } 1159 }
1160 Utils::OpenHandle(this)->set_internal_field_count(i::Smi::FromInt(value)); 1160 Utils::OpenHandle(this)->set_internal_field_count(i::Smi::FromInt(value));
1161 } 1161 }
1162 1162
1163 1163
1164 // --- S c r i p t D a t a --- 1164 // --- S c r i p t D a t a ---
1165 1165
1166 1166
1167 ScriptData* ScriptData::PreCompile(const char* input, int length) { 1167 ScriptData* ScriptData::PreCompile(const char* input, int length) {
1168 unibrow::Utf8InputBuffer<> buf(input, length); 1168 i::Utf8ToUC16CharacterStream stream(
1169 return i::ParserApi::PreParse(i::Handle<i::String>(), &buf, NULL); 1169 reinterpret_cast<const unsigned char*>(input), length);
1170 return i::ParserApi::PreParse(&stream, NULL);
1170 } 1171 }
1171 1172
1172 1173
1173 ScriptData* ScriptData::PreCompile(v8::Handle<String> source) { 1174 ScriptData* ScriptData::PreCompile(v8::Handle<String> source) {
1174 i::Handle<i::String> str = Utils::OpenHandle(*source); 1175 i::Handle<i::String> str = Utils::OpenHandle(*source);
1175 return i::ParserApi::PreParse(str, NULL, NULL); 1176 if (str->IsExternalTwoByteString()) {
1177 i::ExternalTwoByteStringUC16CharacterStream stream(
1178 i::Handle<i::ExternalTwoByteString>::cast(str), 0, str->length());
1179 return i::ParserApi::PreParse(&stream, NULL);
1180 } else {
1181 i::GenericStringUC16CharacterStream stream(str, 0, str->length());
1182 return i::ParserApi::PreParse(&stream, NULL);
1183 }
1176 } 1184 }
1177 1185
1178 1186
1179 ScriptData* ScriptData::New(const char* data, int length) { 1187 ScriptData* ScriptData::New(const char* data, int length) {
1180 // Return an empty ScriptData if the length is obviously invalid. 1188 // Return an empty ScriptData if the length is obviously invalid.
1181 if (length % sizeof(unsigned) != 0) { 1189 if (length % sizeof(unsigned) != 0) {
1182 return new i::ScriptDataImpl(); 1190 return new i::ScriptDataImpl();
1183 } 1191 }
1184 1192
1185 // Copy the data to ensure it is properly aligned. 1193 // Copy the data to ensure it is properly aligned.
(...skipping 3909 matching lines...) Expand 10 before | Expand all | Expand 10 after
5095 5103
5096 5104
5097 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { 5105 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) {
5098 HandleScopeImplementer* thread_local = 5106 HandleScopeImplementer* thread_local =
5099 reinterpret_cast<HandleScopeImplementer*>(storage); 5107 reinterpret_cast<HandleScopeImplementer*>(storage);
5100 thread_local->IterateThis(v); 5108 thread_local->IterateThis(v);
5101 return storage + ArchiveSpacePerThread(); 5109 return storage + ArchiveSpacePerThread();
5102 } 5110 }
5103 5111
5104 } } // namespace v8::internal 5112 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/checks.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698