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

Side by Side Diff: src/api.cc

Issue 606053: Enable passing of script data via script creation methods (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: '' Created 10 years, 10 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 | « include/v8.h ('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 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after
1099 ScriptData* ScriptData::New(unsigned* data, int length) { 1099 ScriptData* ScriptData::New(unsigned* data, int length) {
1100 return new i::ScriptDataImpl(i::Vector<unsigned>(data, length)); 1100 return new i::ScriptDataImpl(i::Vector<unsigned>(data, length));
1101 } 1101 }
1102 1102
1103 1103
1104 // --- S c r i p t --- 1104 // --- S c r i p t ---
1105 1105
1106 1106
1107 Local<Script> Script::New(v8::Handle<String> source, 1107 Local<Script> Script::New(v8::Handle<String> source,
1108 v8::ScriptOrigin* origin, 1108 v8::ScriptOrigin* origin,
1109 v8::ScriptData* script_data) { 1109 v8::ScriptData* pre_data,
1110 v8::Handle<String> script_data) {
1110 ON_BAILOUT("v8::Script::New()", return Local<Script>()); 1111 ON_BAILOUT("v8::Script::New()", return Local<Script>());
1111 LOG_API("Script::New"); 1112 LOG_API("Script::New");
1112 ENTER_V8; 1113 ENTER_V8;
1113 i::Handle<i::String> str = Utils::OpenHandle(*source); 1114 i::Handle<i::String> str = Utils::OpenHandle(*source);
1114 i::Handle<i::Object> name_obj; 1115 i::Handle<i::Object> name_obj;
1115 int line_offset = 0; 1116 int line_offset = 0;
1116 int column_offset = 0; 1117 int column_offset = 0;
1117 if (origin != NULL) { 1118 if (origin != NULL) {
1118 if (!origin->ResourceName().IsEmpty()) { 1119 if (!origin->ResourceName().IsEmpty()) {
1119 name_obj = Utils::OpenHandle(*origin->ResourceName()); 1120 name_obj = Utils::OpenHandle(*origin->ResourceName());
1120 } 1121 }
1121 if (!origin->ResourceLineOffset().IsEmpty()) { 1122 if (!origin->ResourceLineOffset().IsEmpty()) {
1122 line_offset = static_cast<int>(origin->ResourceLineOffset()->Value()); 1123 line_offset = static_cast<int>(origin->ResourceLineOffset()->Value());
1123 } 1124 }
1124 if (!origin->ResourceColumnOffset().IsEmpty()) { 1125 if (!origin->ResourceColumnOffset().IsEmpty()) {
1125 column_offset = static_cast<int>(origin->ResourceColumnOffset()->Value()); 1126 column_offset = static_cast<int>(origin->ResourceColumnOffset()->Value());
1126 } 1127 }
1127 } 1128 }
1128 EXCEPTION_PREAMBLE(); 1129 EXCEPTION_PREAMBLE();
1129 i::ScriptDataImpl* pre_data = static_cast<i::ScriptDataImpl*>(script_data); 1130 i::ScriptDataImpl* pre_data_impl = static_cast<i::ScriptDataImpl*>(pre_data);
1130 // We assert that the pre-data is sane, even though we can actually 1131 // We assert that the pre-data is sane, even though we can actually
1131 // handle it if it turns out not to be in release mode. 1132 // handle it if it turns out not to be in release mode.
1132 ASSERT(pre_data == NULL || pre_data->SanityCheck()); 1133 ASSERT(pre_data_impl == NULL || pre_data_impl->SanityCheck());
1133 // If the pre-data isn't sane we simply ignore it 1134 // If the pre-data isn't sane we simply ignore it
1134 if (pre_data != NULL && !pre_data->SanityCheck()) { 1135 if (pre_data_impl != NULL && !pre_data_impl->SanityCheck()) {
1135 pre_data = NULL; 1136 pre_data_impl = NULL;
1136 } 1137 }
1137 i::Handle<i::JSFunction> boilerplate = i::Compiler::Compile(str, 1138 i::Handle<i::JSFunction> boilerplate =
1138 name_obj, 1139 i::Compiler::Compile(str, name_obj, line_offset, column_offset, NULL,
1139 line_offset, 1140 pre_data_impl, Utils::OpenHandle(*script_data));
1140 column_offset,
1141 NULL,
1142 pre_data);
1143 has_pending_exception = boilerplate.is_null(); 1141 has_pending_exception = boilerplate.is_null();
1144 EXCEPTION_BAILOUT_CHECK(Local<Script>()); 1142 EXCEPTION_BAILOUT_CHECK(Local<Script>());
1145 return Local<Script>(ToApi<Script>(boilerplate)); 1143 return Local<Script>(ToApi<Script>(boilerplate));
1146 } 1144 }
1147 1145
1148 1146
1149 Local<Script> Script::New(v8::Handle<String> source, 1147 Local<Script> Script::New(v8::Handle<String> source,
1150 v8::Handle<Value> file_name) { 1148 v8::Handle<Value> file_name) {
1151 ScriptOrigin origin(file_name); 1149 ScriptOrigin origin(file_name);
1152 return New(source, &origin); 1150 return New(source, &origin);
1153 } 1151 }
1154 1152
1155 1153
1156 Local<Script> Script::Compile(v8::Handle<String> source, 1154 Local<Script> Script::Compile(v8::Handle<String> source,
1157 v8::ScriptOrigin* origin, 1155 v8::ScriptOrigin* origin,
1158 v8::ScriptData* script_data) { 1156 v8::ScriptData* pre_data,
1157 v8::Handle<String> script_data) {
1159 ON_BAILOUT("v8::Script::Compile()", return Local<Script>()); 1158 ON_BAILOUT("v8::Script::Compile()", return Local<Script>());
1160 LOG_API("Script::Compile"); 1159 LOG_API("Script::Compile");
1161 ENTER_V8; 1160 ENTER_V8;
1162 Local<Script> generic = New(source, origin, script_data); 1161 Local<Script> generic = New(source, origin, pre_data, script_data);
1163 if (generic.IsEmpty()) 1162 if (generic.IsEmpty())
1164 return generic; 1163 return generic;
1165 i::Handle<i::JSFunction> boilerplate = Utils::OpenHandle(*generic); 1164 i::Handle<i::JSFunction> boilerplate = Utils::OpenHandle(*generic);
1166 i::Handle<i::JSFunction> result = 1165 i::Handle<i::JSFunction> result =
1167 i::Factory::NewFunctionFromBoilerplate(boilerplate, 1166 i::Factory::NewFunctionFromBoilerplate(boilerplate,
1168 i::Top::global_context()); 1167 i::Top::global_context());
1169 return Local<Script>(ToApi<Script>(result)); 1168 return Local<Script>(ToApi<Script>(result));
1170 } 1169 }
1171 1170
1172 1171
1173 Local<Script> Script::Compile(v8::Handle<String> source, 1172 Local<Script> Script::Compile(v8::Handle<String> source,
1174 v8::Handle<Value> file_name) { 1173 v8::Handle<Value> file_name,
1174 v8::Handle<String> script_data) {
1175 ScriptOrigin origin(file_name); 1175 ScriptOrigin origin(file_name);
1176 return Compile(source, &origin); 1176 return Compile(source, &origin, 0, script_data);
1177 } 1177 }
1178 1178
1179 1179
1180 Local<Value> Script::Run() { 1180 Local<Value> Script::Run() {
1181 ON_BAILOUT("v8::Script::Run()", return Local<Value>()); 1181 ON_BAILOUT("v8::Script::Run()", return Local<Value>());
1182 LOG_API("Script::Run"); 1182 LOG_API("Script::Run");
1183 ENTER_V8; 1183 ENTER_V8;
1184 i::Object* raw_result = NULL; 1184 i::Object* raw_result = NULL;
1185 { 1185 {
1186 HandleScope scope; 1186 HandleScope scope;
(...skipping 2639 matching lines...) Expand 10 before | Expand all | Expand 10 after
3826 3826
3827 3827
3828 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { 3828 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) {
3829 HandleScopeImplementer* thread_local = 3829 HandleScopeImplementer* thread_local =
3830 reinterpret_cast<HandleScopeImplementer*>(storage); 3830 reinterpret_cast<HandleScopeImplementer*>(storage);
3831 thread_local->IterateThis(v); 3831 thread_local->IterateThis(v);
3832 return storage + ArchiveSpacePerThread(); 3832 return storage + ArchiveSpacePerThread();
3833 } 3833 }
3834 3834
3835 } } // namespace v8::internal 3835 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698