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

Side by Side Diff: src/api.cc

Issue 669240: - Remove function boilerplate objects and use SharedFunctionInfos in... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Committed Created 10 years, 9 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 | « src/api.h ('k') | src/arm/codegen-arm.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 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 EXCEPTION_PREAMBLE(); 1130 EXCEPTION_PREAMBLE();
1131 i::ScriptDataImpl* pre_data_impl = static_cast<i::ScriptDataImpl*>(pre_data); 1131 i::ScriptDataImpl* pre_data_impl = static_cast<i::ScriptDataImpl*>(pre_data);
1132 // We assert that the pre-data is sane, even though we can actually 1132 // We assert that the pre-data is sane, even though we can actually
1133 // handle it if it turns out not to be in release mode. 1133 // handle it if it turns out not to be in release mode.
1134 ASSERT(pre_data_impl == NULL || pre_data_impl->SanityCheck()); 1134 ASSERT(pre_data_impl == NULL || pre_data_impl->SanityCheck());
1135 // If the pre-data isn't sane we simply ignore it 1135 // If the pre-data isn't sane we simply ignore it
1136 if (pre_data_impl != NULL && !pre_data_impl->SanityCheck()) { 1136 if (pre_data_impl != NULL && !pre_data_impl->SanityCheck()) {
1137 pre_data_impl = NULL; 1137 pre_data_impl = NULL;
1138 } 1138 }
1139 i::Handle<i::JSFunction> boilerplate = 1139 i::Handle<i::SharedFunctionInfo> result =
1140 i::Compiler::Compile(str, 1140 i::Compiler::Compile(str,
1141 name_obj, 1141 name_obj,
1142 line_offset, 1142 line_offset,
1143 column_offset, 1143 column_offset,
1144 NULL, 1144 NULL,
1145 pre_data_impl, 1145 pre_data_impl,
1146 Utils::OpenHandle(*script_data), 1146 Utils::OpenHandle(*script_data),
1147 i::NOT_NATIVES_CODE); 1147 i::NOT_NATIVES_CODE);
1148 has_pending_exception = boilerplate.is_null(); 1148 has_pending_exception = result.is_null();
1149 EXCEPTION_BAILOUT_CHECK(Local<Script>()); 1149 EXCEPTION_BAILOUT_CHECK(Local<Script>());
1150 return Local<Script>(ToApi<Script>(boilerplate)); 1150 return Local<Script>(ToApi<Script>(result));
1151 } 1151 }
1152 1152
1153 1153
1154 Local<Script> Script::New(v8::Handle<String> source, 1154 Local<Script> Script::New(v8::Handle<String> source,
1155 v8::Handle<Value> file_name) { 1155 v8::Handle<Value> file_name) {
1156 ScriptOrigin origin(file_name); 1156 ScriptOrigin origin(file_name);
1157 return New(source, &origin); 1157 return New(source, &origin);
1158 } 1158 }
1159 1159
1160 1160
1161 Local<Script> Script::Compile(v8::Handle<String> source, 1161 Local<Script> Script::Compile(v8::Handle<String> source,
1162 v8::ScriptOrigin* origin, 1162 v8::ScriptOrigin* origin,
1163 v8::ScriptData* pre_data, 1163 v8::ScriptData* pre_data,
1164 v8::Handle<String> script_data) { 1164 v8::Handle<String> script_data) {
1165 ON_BAILOUT("v8::Script::Compile()", return Local<Script>()); 1165 ON_BAILOUT("v8::Script::Compile()", return Local<Script>());
1166 LOG_API("Script::Compile"); 1166 LOG_API("Script::Compile");
1167 ENTER_V8; 1167 ENTER_V8;
1168 Local<Script> generic = New(source, origin, pre_data, script_data); 1168 Local<Script> generic = New(source, origin, pre_data, script_data);
1169 if (generic.IsEmpty()) 1169 if (generic.IsEmpty())
1170 return generic; 1170 return generic;
1171 i::Handle<i::JSFunction> boilerplate = Utils::OpenHandle(*generic); 1171 i::Handle<i::Object> obj = Utils::OpenHandle(*generic);
1172 i::Handle<i::SharedFunctionInfo> function =
1173 i::Handle<i::SharedFunctionInfo>(i::SharedFunctionInfo::cast(*obj));
1172 i::Handle<i::JSFunction> result = 1174 i::Handle<i::JSFunction> result =
1173 i::Factory::NewFunctionFromBoilerplate(boilerplate, 1175 i::Factory::NewFunctionFromSharedFunctionInfo(function,
1174 i::Top::global_context()); 1176 i::Top::global_context());
1175 return Local<Script>(ToApi<Script>(result)); 1177 return Local<Script>(ToApi<Script>(result));
1176 } 1178 }
1177 1179
1178 1180
1179 Local<Script> Script::Compile(v8::Handle<String> source, 1181 Local<Script> Script::Compile(v8::Handle<String> source,
1180 v8::Handle<Value> file_name, 1182 v8::Handle<Value> file_name,
1181 v8::Handle<String> script_data) { 1183 v8::Handle<String> script_data) {
1182 ScriptOrigin origin(file_name); 1184 ScriptOrigin origin(file_name);
1183 return Compile(source, &origin, 0, script_data); 1185 return Compile(source, &origin, 0, script_data);
1184 } 1186 }
1185 1187
1186 1188
1187 Local<Value> Script::Run() { 1189 Local<Value> Script::Run() {
1188 ON_BAILOUT("v8::Script::Run()", return Local<Value>()); 1190 ON_BAILOUT("v8::Script::Run()", return Local<Value>());
1189 LOG_API("Script::Run"); 1191 LOG_API("Script::Run");
1190 ENTER_V8; 1192 ENTER_V8;
1191 i::Object* raw_result = NULL; 1193 i::Object* raw_result = NULL;
1192 { 1194 {
1193 HandleScope scope; 1195 HandleScope scope;
1194 i::Handle<i::JSFunction> fun = Utils::OpenHandle(this); 1196 i::Handle<i::Object> obj = Utils::OpenHandle(this);
1195 if (fun->IsBoilerplate()) { 1197 i::Handle<i::JSFunction> fun;
1196 fun = i::Factory::NewFunctionFromBoilerplate(fun, 1198 if (obj->IsSharedFunctionInfo()) {
1197 i::Top::global_context()); 1199 i::Handle<i::SharedFunctionInfo>
1200 function_info(i::SharedFunctionInfo::cast(*obj));
1201 fun = i::Factory::NewFunctionFromSharedFunctionInfo(
1202 function_info, i::Top::global_context());
1203 } else {
1204 fun = i::Handle<i::JSFunction>(i::JSFunction::cast(*obj));
1198 } 1205 }
1199 EXCEPTION_PREAMBLE(); 1206 EXCEPTION_PREAMBLE();
1200 i::Handle<i::Object> receiver(i::Top::context()->global_proxy()); 1207 i::Handle<i::Object> receiver(i::Top::context()->global_proxy());
1201 i::Handle<i::Object> result = 1208 i::Handle<i::Object> result =
1202 i::Execution::Call(fun, receiver, 0, NULL, &has_pending_exception); 1209 i::Execution::Call(fun, receiver, 0, NULL, &has_pending_exception);
1203 EXCEPTION_BAILOUT_CHECK(Local<Value>()); 1210 EXCEPTION_BAILOUT_CHECK(Local<Value>());
1204 raw_result = *result; 1211 raw_result = *result;
1205 } 1212 }
1206 i::Handle<i::Object> result(raw_result); 1213 i::Handle<i::Object> result(raw_result);
1207 return Utils::ToLocal(result); 1214 return Utils::ToLocal(result);
1208 } 1215 }
1209 1216
1210 1217
1218 static i::Handle<i::SharedFunctionInfo> OpenScript(Script* script) {
1219 i::Handle<i::Object> obj = Utils::OpenHandle(script);
1220 i::Handle<i::SharedFunctionInfo> result;
1221 if (obj->IsSharedFunctionInfo()) {
1222 result =
1223 i::Handle<i::SharedFunctionInfo>(i::SharedFunctionInfo::cast(*obj));
1224 } else {
1225 result =
1226 i::Handle<i::SharedFunctionInfo>(i::JSFunction::cast(*obj)->shared());
1227 }
1228 return result;
1229 }
1230
1231
1211 Local<Value> Script::Id() { 1232 Local<Value> Script::Id() {
1212 ON_BAILOUT("v8::Script::Id()", return Local<Value>()); 1233 ON_BAILOUT("v8::Script::Id()", return Local<Value>());
1213 LOG_API("Script::Id"); 1234 LOG_API("Script::Id");
1214 i::Object* raw_id = NULL; 1235 i::Object* raw_id = NULL;
1215 { 1236 {
1216 HandleScope scope; 1237 HandleScope scope;
1217 i::Handle<i::JSFunction> fun = Utils::OpenHandle(this); 1238 i::Handle<i::SharedFunctionInfo> function_info = OpenScript(this);
1218 i::Handle<i::Script> script(i::Script::cast(fun->shared()->script())); 1239 i::Handle<i::Script> script(i::Script::cast(function_info->script()));
1219 i::Handle<i::Object> id(script->id()); 1240 i::Handle<i::Object> id(script->id());
1220 raw_id = *id; 1241 raw_id = *id;
1221 } 1242 }
1222 i::Handle<i::Object> id(raw_id); 1243 i::Handle<i::Object> id(raw_id);
1223 return Utils::ToLocal(id); 1244 return Utils::ToLocal(id);
1224 } 1245 }
1225 1246
1226 1247
1227 void Script::SetData(v8::Handle<String> data) { 1248 void Script::SetData(v8::Handle<String> data) {
1228 ON_BAILOUT("v8::Script::SetData()", return); 1249 ON_BAILOUT("v8::Script::SetData()", return);
1229 LOG_API("Script::SetData"); 1250 LOG_API("Script::SetData");
1230 { 1251 {
1231 HandleScope scope; 1252 HandleScope scope;
1232 i::Handle<i::JSFunction> fun = Utils::OpenHandle(this); 1253 i::Handle<i::SharedFunctionInfo> function_info = OpenScript(this);
1233 i::Handle<i::Object> raw_data = Utils::OpenHandle(*data); 1254 i::Handle<i::Object> raw_data = Utils::OpenHandle(*data);
1234 i::Handle<i::Script> script(i::Script::cast(fun->shared()->script())); 1255 i::Handle<i::Script> script(i::Script::cast(function_info->script()));
1235 script->set_data(*raw_data); 1256 script->set_data(*raw_data);
1236 } 1257 }
1237 } 1258 }
1238 1259
1239 1260
1240 // --- E x c e p t i o n s --- 1261 // --- E x c e p t i o n s ---
1241 1262
1242 1263
1243 v8::TryCatch::TryCatch() 1264 v8::TryCatch::TryCatch()
1244 : next_(i::Top::try_catch_handler_address()), 1265 : next_(i::Top::try_catch_handler_address()),
(...skipping 2761 matching lines...) Expand 10 before | Expand all | Expand 10 after
4006 4027
4007 4028
4008 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { 4029 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) {
4009 HandleScopeImplementer* thread_local = 4030 HandleScopeImplementer* thread_local =
4010 reinterpret_cast<HandleScopeImplementer*>(storage); 4031 reinterpret_cast<HandleScopeImplementer*>(storage);
4011 thread_local->IterateThis(v); 4032 thread_local->IterateThis(v);
4012 return storage + ArchiveSpacePerThread(); 4033 return storage + ArchiveSpacePerThread();
4013 } 4034 }
4014 4035
4015 } } // namespace v8::internal 4036 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/api.h ('k') | src/arm/codegen-arm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698