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

Side by Side Diff: src/api.cc

Issue 5545006: Optimized scanner to avoid virtual calls for every character read. (Closed)
Patch Set: 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') | src/compiler.cc » ('J')
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 1142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1153 EnsureConstructor(this); 1153 EnsureConstructor(this);
1154 } 1154 }
1155 Utils::OpenHandle(this)->set_internal_field_count(i::Smi::FromInt(value)); 1155 Utils::OpenHandle(this)->set_internal_field_count(i::Smi::FromInt(value));
1156 } 1156 }
1157 1157
1158 1158
1159 // --- S c r i p t D a t a --- 1159 // --- S c r i p t D a t a ---
1160 1160
1161 1161
1162 ScriptData* ScriptData::PreCompile(const char* input, int length) { 1162 ScriptData* ScriptData::PreCompile(const char* input, int length) {
1163 unibrow::Utf8InputBuffer<> buf(input, length); 1163 i::Utf8ToUC16CharacterStream stream(
1164 return i::ParserApi::PreParse(i::Handle<i::String>(), &buf, NULL); 1164 reinterpret_cast<const unsigned char*>(input), length);
1165 return i::ParserApi::PreParse(&stream, NULL);
1165 } 1166 }
1166 1167
1167 1168
1168 ScriptData* ScriptData::PreCompile(v8::Handle<String> source) { 1169 ScriptData* ScriptData::PreCompile(v8::Handle<String> source) {
1169 i::Handle<i::String> str = Utils::OpenHandle(*source); 1170 i::Handle<i::String> str = Utils::OpenHandle(*source);
1170 return i::ParserApi::PreParse(str, NULL, NULL); 1171 if (str->IsExternalTwoByteString()) {
1172 i::ExternalTwoByteStringUC16CharacterStream stream(
1173 i::Handle<i::ExternalTwoByteString>::cast(str), 0, str->length());
1174 return i::ParserApi::PreParse(&stream, NULL);
1175 } else {
1176 i::GenericStringUC16CharacterStream stream(str, 0, str->length());
1177 return i::ParserApi::PreParse(&stream, NULL);
1178 }
1171 } 1179 }
1172 1180
1173 1181
1174 ScriptData* ScriptData::New(const char* data, int length) { 1182 ScriptData* ScriptData::New(const char* data, int length) {
1175 // Return an empty ScriptData if the length is obviously invalid. 1183 // Return an empty ScriptData if the length is obviously invalid.
1176 if (length % sizeof(unsigned) != 0) { 1184 if (length % sizeof(unsigned) != 0) {
1177 return new i::ScriptDataImpl(); 1185 return new i::ScriptDataImpl();
1178 } 1186 }
1179 1187
1180 // Copy the data to ensure it is properly aligned. 1188 // Copy the data to ensure it is properly aligned.
(...skipping 3840 matching lines...) Expand 10 before | Expand all | Expand 10 after
5021 5029
5022 5030
5023 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { 5031 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) {
5024 HandleScopeImplementer* thread_local = 5032 HandleScopeImplementer* thread_local =
5025 reinterpret_cast<HandleScopeImplementer*>(storage); 5033 reinterpret_cast<HandleScopeImplementer*>(storage);
5026 thread_local->IterateThis(v); 5034 thread_local->IterateThis(v);
5027 return storage + ArchiveSpacePerThread(); 5035 return storage + ArchiveSpacePerThread();
5028 } 5036 }
5029 5037
5030 } } // namespace v8::internal 5038 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/checks.h » ('j') | src/compiler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698