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

Side by Side Diff: src/api.cc

Issue 90003: Make it possible to add a user data object to each script compiled (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 8 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/accessors.cc ('k') | src/bootstrapper.cc » ('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 1090 matching lines...) Expand 10 before | Expand all | Expand 10 after
1101 i::Handle<i::JSFunction> fun = Utils::OpenHandle(this); 1101 i::Handle<i::JSFunction> fun = Utils::OpenHandle(this);
1102 i::Handle<i::Script> script(i::Script::cast(fun->shared()->script())); 1102 i::Handle<i::Script> script(i::Script::cast(fun->shared()->script()));
1103 i::Handle<i::Object> id(script->id()); 1103 i::Handle<i::Object> id(script->id());
1104 raw_id = *id; 1104 raw_id = *id;
1105 } 1105 }
1106 i::Handle<i::Object> id(raw_id); 1106 i::Handle<i::Object> id(raw_id);
1107 return Utils::ToLocal(id); 1107 return Utils::ToLocal(id);
1108 } 1108 }
1109 1109
1110 1110
1111 void Script::SetData(v8::Handle<Value> data) {
1112 ON_BAILOUT("v8::Script::SetData()", return);
1113 LOG_API("Script::SetData");
1114 {
1115 HandleScope scope;
1116 i::Handle<i::JSFunction> fun = Utils::OpenHandle(this);
1117 i::Handle<i::Object> raw_data = Utils::OpenHandle(*data);
1118 i::Handle<i::Script> script(i::Script::cast(fun->shared()->script()));
1119 script->set_data(*raw_data);
1120 }
1121 }
1122
1123
1111 // --- E x c e p t i o n s --- 1124 // --- E x c e p t i o n s ---
1112 1125
1113 1126
1114 v8::TryCatch::TryCatch() 1127 v8::TryCatch::TryCatch()
1115 : next_(i::Top::try_catch_handler()), 1128 : next_(i::Top::try_catch_handler()),
1116 exception_(i::Heap::the_hole_value()), 1129 exception_(i::Heap::the_hole_value()),
1117 message_(i::Smi::FromInt(0)), 1130 message_(i::Smi::FromInt(0)),
1118 is_verbose_(false), 1131 is_verbose_(false),
1119 capture_message_(true), 1132 capture_message_(true),
1120 js_handler_(NULL) { 1133 js_handler_(NULL) {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1192 i::Handle<i::JSObject> obj = 1205 i::Handle<i::JSObject> obj =
1193 i::Handle<i::JSObject>::cast(Utils::OpenHandle(this)); 1206 i::Handle<i::JSObject>::cast(Utils::OpenHandle(this));
1194 // Return this.script.name. 1207 // Return this.script.name.
1195 i::Handle<i::JSValue> script = 1208 i::Handle<i::JSValue> script =
1196 i::Handle<i::JSValue>::cast(GetProperty(obj, "script")); 1209 i::Handle<i::JSValue>::cast(GetProperty(obj, "script"));
1197 i::Handle<i::Object> resource_name(i::Script::cast(script->value())->name()); 1210 i::Handle<i::Object> resource_name(i::Script::cast(script->value())->name());
1198 return scope.Close(Utils::ToLocal(resource_name)); 1211 return scope.Close(Utils::ToLocal(resource_name));
1199 } 1212 }
1200 1213
1201 1214
1215 v8::Handle<Value> Message::GetScriptData() const {
1216 if (IsDeadCheck("v8::Message::GetScriptResourceData()")) {
1217 return Local<Value>();
1218 }
1219 ENTER_V8;
1220 HandleScope scope;
1221 i::Handle<i::JSObject> obj =
1222 i::Handle<i::JSObject>::cast(Utils::OpenHandle(this));
1223 // Return this.script.data.
1224 i::Handle<i::JSValue> script =
1225 i::Handle<i::JSValue>::cast(GetProperty(obj, "script"));
1226 i::Handle<i::Object> data(i::Script::cast(script->value())->data());
1227 return scope.Close(Utils::ToLocal(data));
1228 }
1229
1230
1202 static i::Handle<i::Object> CallV8HeapFunction(const char* name, 1231 static i::Handle<i::Object> CallV8HeapFunction(const char* name,
1203 i::Handle<i::Object> recv, 1232 i::Handle<i::Object> recv,
1204 int argc, 1233 int argc,
1205 i::Object** argv[], 1234 i::Object** argv[],
1206 bool* has_pending_exception) { 1235 bool* has_pending_exception) {
1207 i::Handle<i::String> fmt_str = i::Factory::LookupAsciiSymbol(name); 1236 i::Handle<i::String> fmt_str = i::Factory::LookupAsciiSymbol(name);
1208 i::Object* object_fun = i::Top::builtins()->GetProperty(*fmt_str); 1237 i::Object* object_fun = i::Top::builtins()->GetProperty(*fmt_str);
1209 i::Handle<i::JSFunction> fun = 1238 i::Handle<i::JSFunction> fun =
1210 i::Handle<i::JSFunction>(i::JSFunction::cast(object_fun)); 1239 i::Handle<i::JSFunction>(i::JSFunction::cast(object_fun));
1211 i::Handle<i::Object> value = 1240 i::Handle<i::Object> value =
(...skipping 2127 matching lines...) Expand 10 before | Expand all | Expand 10 after
3339 reinterpret_cast<HandleScopeImplementer*>(storage); 3368 reinterpret_cast<HandleScopeImplementer*>(storage);
3340 List<void**>* blocks_of_archived_thread = thread_local->Blocks(); 3369 List<void**>* blocks_of_archived_thread = thread_local->Blocks();
3341 v8::ImplementationUtilities::HandleScopeData* handle_data_of_archived_thread = 3370 v8::ImplementationUtilities::HandleScopeData* handle_data_of_archived_thread =
3342 &thread_local->handle_scope_data_; 3371 &thread_local->handle_scope_data_;
3343 Iterate(v, blocks_of_archived_thread, handle_data_of_archived_thread); 3372 Iterate(v, blocks_of_archived_thread, handle_data_of_archived_thread);
3344 3373
3345 return storage + ArchiveSpacePerThread(); 3374 return storage + ArchiveSpacePerThread();
3346 } 3375 }
3347 3376
3348 } } // namespace v8::internal 3377 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/accessors.cc ('k') | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698