| OLD | NEW |
| 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 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1051 | 1051 |
| 1052 | 1052 |
| 1053 ScriptData* ScriptData::New(unsigned* data, int length) { | 1053 ScriptData* ScriptData::New(unsigned* data, int length) { |
| 1054 return new i::ScriptDataImpl(i::Vector<unsigned>(data, length)); | 1054 return new i::ScriptDataImpl(i::Vector<unsigned>(data, length)); |
| 1055 } | 1055 } |
| 1056 | 1056 |
| 1057 | 1057 |
| 1058 // --- S c r i p t --- | 1058 // --- S c r i p t --- |
| 1059 | 1059 |
| 1060 | 1060 |
| 1061 Local<Script> Script::Compile(v8::Handle<String> source, | 1061 Local<Script> Script::New(v8::Handle<String> source, |
| 1062 v8::ScriptOrigin* origin, | 1062 v8::ScriptOrigin* origin, |
| 1063 v8::ScriptData* script_data) { | 1063 v8::ScriptData* script_data) { |
| 1064 ON_BAILOUT("v8::Script::Compile()", return Local<Script>()); | 1064 ON_BAILOUT("v8::Script::New()", return Local<Script>()); |
| 1065 LOG_API("Script::Compile"); | 1065 LOG_API("Script::New"); |
| 1066 ENTER_V8; | 1066 ENTER_V8; |
| 1067 i::Handle<i::String> str = Utils::OpenHandle(*source); | 1067 i::Handle<i::String> str = Utils::OpenHandle(*source); |
| 1068 i::Handle<i::Object> name_obj; | 1068 i::Handle<i::Object> name_obj; |
| 1069 int line_offset = 0; | 1069 int line_offset = 0; |
| 1070 int column_offset = 0; | 1070 int column_offset = 0; |
| 1071 if (origin != NULL) { | 1071 if (origin != NULL) { |
| 1072 if (!origin->ResourceName().IsEmpty()) { | 1072 if (!origin->ResourceName().IsEmpty()) { |
| 1073 name_obj = Utils::OpenHandle(*origin->ResourceName()); | 1073 name_obj = Utils::OpenHandle(*origin->ResourceName()); |
| 1074 } | 1074 } |
| 1075 if (!origin->ResourceLineOffset().IsEmpty()) { | 1075 if (!origin->ResourceLineOffset().IsEmpty()) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1089 pre_data = NULL; | 1089 pre_data = NULL; |
| 1090 } | 1090 } |
| 1091 i::Handle<i::JSFunction> boilerplate = i::Compiler::Compile(str, | 1091 i::Handle<i::JSFunction> boilerplate = i::Compiler::Compile(str, |
| 1092 name_obj, | 1092 name_obj, |
| 1093 line_offset, | 1093 line_offset, |
| 1094 column_offset, | 1094 column_offset, |
| 1095 NULL, | 1095 NULL, |
| 1096 pre_data); | 1096 pre_data); |
| 1097 has_pending_exception = boilerplate.is_null(); | 1097 has_pending_exception = boilerplate.is_null(); |
| 1098 EXCEPTION_BAILOUT_CHECK(Local<Script>()); | 1098 EXCEPTION_BAILOUT_CHECK(Local<Script>()); |
| 1099 return Local<Script>(ToApi<Script>(boilerplate)); |
| 1100 } |
| 1101 |
| 1102 |
| 1103 Local<Script> Script::New(v8::Handle<String> source, |
| 1104 v8::Handle<Value> file_name) { |
| 1105 ScriptOrigin origin(file_name); |
| 1106 return New(source, &origin); |
| 1107 } |
| 1108 |
| 1109 |
| 1110 Local<Script> Script::Compile(v8::Handle<String> source, |
| 1111 v8::ScriptOrigin* origin, |
| 1112 v8::ScriptData* script_data) { |
| 1113 ON_BAILOUT("v8::Script::Compile()", return Local<Script>()); |
| 1114 LOG_API("Script::Compile"); |
| 1115 ENTER_V8; |
| 1116 Local<Script> generic = New(source, origin, script_data); |
| 1117 if (generic.IsEmpty()) |
| 1118 return generic; |
| 1119 i::Handle<i::JSFunction> boilerplate = Utils::OpenHandle(*generic); |
| 1099 i::Handle<i::JSFunction> result = | 1120 i::Handle<i::JSFunction> result = |
| 1100 i::Factory::NewFunctionFromBoilerplate(boilerplate, | 1121 i::Factory::NewFunctionFromBoilerplate(boilerplate, |
| 1101 i::Top::global_context()); | 1122 i::Top::global_context()); |
| 1102 return Local<Script>(ToApi<Script>(result)); | 1123 return Local<Script>(ToApi<Script>(result)); |
| 1103 } | 1124 } |
| 1104 | 1125 |
| 1105 | 1126 |
| 1106 Local<Script> Script::Compile(v8::Handle<String> source, | 1127 Local<Script> Script::Compile(v8::Handle<String> source, |
| 1107 v8::Handle<Value> file_name) { | 1128 v8::Handle<Value> file_name) { |
| 1108 ScriptOrigin origin(file_name); | 1129 ScriptOrigin origin(file_name); |
| 1109 return Compile(source, &origin); | 1130 return Compile(source, &origin); |
| 1110 } | 1131 } |
| 1111 | 1132 |
| 1112 | 1133 |
| 1113 Local<Value> Script::Run() { | 1134 Local<Value> Script::Run() { |
| 1114 ON_BAILOUT("v8::Script::Run()", return Local<Value>()); | 1135 ON_BAILOUT("v8::Script::Run()", return Local<Value>()); |
| 1115 LOG_API("Script::Run"); | 1136 LOG_API("Script::Run"); |
| 1116 ENTER_V8; | 1137 ENTER_V8; |
| 1117 i::Object* raw_result = NULL; | 1138 i::Object* raw_result = NULL; |
| 1118 { | 1139 { |
| 1119 HandleScope scope; | 1140 HandleScope scope; |
| 1120 i::Handle<i::JSFunction> fun = Utils::OpenHandle(this); | 1141 i::Handle<i::JSFunction> fun = Utils::OpenHandle(this); |
| 1142 if (fun->IsBoilerplate()) { |
| 1143 fun = i::Factory::NewFunctionFromBoilerplate(fun, |
| 1144 i::Top::global_context()); |
| 1145 } |
| 1121 EXCEPTION_PREAMBLE(); | 1146 EXCEPTION_PREAMBLE(); |
| 1122 i::Handle<i::Object> receiver(i::Top::context()->global_proxy()); | 1147 i::Handle<i::Object> receiver(i::Top::context()->global_proxy()); |
| 1123 i::Handle<i::Object> result = | 1148 i::Handle<i::Object> result = |
| 1124 i::Execution::Call(fun, receiver, 0, NULL, &has_pending_exception); | 1149 i::Execution::Call(fun, receiver, 0, NULL, &has_pending_exception); |
| 1125 EXCEPTION_BAILOUT_CHECK(Local<Value>()); | 1150 EXCEPTION_BAILOUT_CHECK(Local<Value>()); |
| 1126 raw_result = *result; | 1151 raw_result = *result; |
| 1127 } | 1152 } |
| 1128 i::Handle<i::Object> result(raw_result); | 1153 i::Handle<i::Object> result(raw_result); |
| 1129 return Utils::ToLocal(result); | 1154 return Utils::ToLocal(result); |
| 1130 } | 1155 } |
| (...skipping 2523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3654 reinterpret_cast<HandleScopeImplementer*>(storage); | 3679 reinterpret_cast<HandleScopeImplementer*>(storage); |
| 3655 List<void**>* blocks_of_archived_thread = thread_local->Blocks(); | 3680 List<void**>* blocks_of_archived_thread = thread_local->Blocks(); |
| 3656 v8::ImplementationUtilities::HandleScopeData* handle_data_of_archived_thread = | 3681 v8::ImplementationUtilities::HandleScopeData* handle_data_of_archived_thread = |
| 3657 &thread_local->handle_scope_data_; | 3682 &thread_local->handle_scope_data_; |
| 3658 Iterate(v, blocks_of_archived_thread, handle_data_of_archived_thread); | 3683 Iterate(v, blocks_of_archived_thread, handle_data_of_archived_thread); |
| 3659 | 3684 |
| 3660 return storage + ArchiveSpacePerThread(); | 3685 return storage + ArchiveSpacePerThread(); |
| 3661 } | 3686 } |
| 3662 | 3687 |
| 3663 } } // namespace v8::internal | 3688 } } // namespace v8::internal |
| OLD | NEW |