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

Side by Side Diff: src/api.cc

Issue 3308010: Avoid (some) symbol lookups at parse time if preparse data is available. (Closed)
Patch Set: Fixed indentation too. Created 10 years, 3 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
« no previous file with comments | « no previous file | src/parser.h » ('j') | test/cctest/test-parsing.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1129 1129
1130 ScriptData* ScriptData::PreCompile(v8::Handle<String> source) { 1130 ScriptData* ScriptData::PreCompile(v8::Handle<String> source) {
1131 i::Handle<i::String> str = Utils::OpenHandle(*source); 1131 i::Handle<i::String> str = Utils::OpenHandle(*source);
1132 return i::PreParse(str, NULL, NULL); 1132 return i::PreParse(str, NULL, NULL);
1133 } 1133 }
1134 1134
1135 1135
1136 ScriptData* ScriptData::New(const char* data, int length) { 1136 ScriptData* ScriptData::New(const char* data, int length) {
1137 // Return an empty ScriptData if the length is obviously invalid. 1137 // Return an empty ScriptData if the length is obviously invalid.
1138 if (length % sizeof(unsigned) != 0) { 1138 if (length % sizeof(unsigned) != 0) {
1139 return new i::ScriptDataImpl(i::Vector<unsigned>()); 1139 return new i::ScriptDataImpl();
1140 } 1140 }
1141 1141
1142 // Copy the data to ensure it is properly aligned. 1142 // Copy the data to ensure it is properly aligned.
1143 int deserialized_data_length = length / sizeof(unsigned); 1143 int deserialized_data_length = length / sizeof(unsigned);
1144 // If aligned, don't create a copy of the data.
1145 if (reinterpret_cast<intptr_t>(data) % sizeof(unsigned) == 0) {
1146 return new i::ScriptDataImpl(data, length);
1147 }
1148 // Copy the data to align it.
1144 unsigned* deserialized_data = i::NewArray<unsigned>(deserialized_data_length); 1149 unsigned* deserialized_data = i::NewArray<unsigned>(deserialized_data_length);
1145 memcpy(deserialized_data, data, length); 1150 i::MemCopy(deserialized_data, data, length);
1146 1151
1147 return new i::ScriptDataImpl( 1152 return new i::ScriptDataImpl(
1148 i::Vector<unsigned>(deserialized_data, deserialized_data_length)); 1153 i::Vector<unsigned>(deserialized_data, deserialized_data_length));
1149 } 1154 }
1150 1155
1151 1156
1152 // --- S c r i p t --- 1157 // --- S c r i p t ---
1153 1158
1154 1159
1155 Local<Script> Script::New(v8::Handle<String> source, 1160 Local<Script> Script::New(v8::Handle<String> source,
(...skipping 3695 matching lines...) Expand 10 before | Expand all | Expand 10 after
4851 4856
4852 4857
4853 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { 4858 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) {
4854 HandleScopeImplementer* thread_local = 4859 HandleScopeImplementer* thread_local =
4855 reinterpret_cast<HandleScopeImplementer*>(storage); 4860 reinterpret_cast<HandleScopeImplementer*>(storage);
4856 thread_local->IterateThis(v); 4861 thread_local->IterateThis(v);
4857 return storage + ArchiveSpacePerThread(); 4862 return storage + ArchiveSpacePerThread();
4858 } 4863 }
4859 4864
4860 } } // namespace v8::internal 4865 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/parser.h » ('j') | test/cctest/test-parsing.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698