Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "include/dart_api.h" | 5 #include "include/dart_api.h" |
| 6 #include "include/dart_mirrors_api.h" | 6 #include "include/dart_mirrors_api.h" |
| 7 #include "include/dart_native_api.h" | 7 #include "include/dart_native_api.h" |
| 8 | 8 |
| 9 #include "lib/stacktrace.h" | 9 #include "lib/stacktrace.h" |
| 10 #include "platform/assert.h" | 10 #include "platform/assert.h" |
| (...skipping 5036 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5047 // Compilation errors are not Dart instances, so just mark the library | 5047 // Compilation errors are not Dart instances, so just mark the library |
| 5048 // as having failed to load without providing an error instance. | 5048 // as having failed to load without providing an error instance. |
| 5049 lib.SetLoadError(Object::null_instance()); | 5049 lib.SetLoadError(Object::null_instance()); |
| 5050 } | 5050 } |
| 5051 } | 5051 } |
| 5052 | 5052 |
| 5053 #if !defined(DART_PRECOMPILED_RUNTIME) | 5053 #if !defined(DART_PRECOMPILED_RUNTIME) |
| 5054 static Dart_Handle LoadKernelProgram(Thread* T, | 5054 static Dart_Handle LoadKernelProgram(Thread* T, |
| 5055 const String& url, | 5055 const String& url, |
| 5056 void* kernel) { | 5056 void* kernel) { |
| 5057 // NOTE: Now the VM owns the [kernel_program] memory! Currently we do not | 5057 // NOTE: Now the VM owns the [kernel_program] memory! |
| 5058 // free it because (similar to the token stream) it will be used to repeatedly | 5058 // We will promptly delete it when done. |
| 5059 // run the `kernel::FlowGraphBuilder()`. | 5059 kernel::Program* program = reinterpret_cast<kernel::Program*>(kernel); |
| 5060 kernel::KernelReader reader(reinterpret_cast<kernel::Program*>(kernel)); | 5060 kernel::KernelReader reader(program); |
| 5061 const Object& tmp = reader.ReadProgram(); | 5061 const Object& tmp = reader.ReadProgram(); |
| 5062 delete program; | |
| 5063 program = NULL; | |
|
Kevin Millikin (Google)
2017/08/14 06:20:50
program = NULL and kernel = NULL don't seem necess
jensj
2017/08/14 08:38:12
Done.
| |
| 5064 kernel = NULL; | |
| 5065 | |
| 5062 if (tmp.IsError()) { | 5066 if (tmp.IsError()) { |
| 5063 return Api::NewHandle(T, tmp.raw()); | 5067 return Api::NewHandle(T, tmp.raw()); |
| 5064 } | 5068 } |
| 5065 return Dart_Null(); | 5069 return Dart_Null(); |
| 5066 } | 5070 } |
| 5067 #endif | 5071 #endif |
| 5068 | 5072 |
| 5069 DART_EXPORT Dart_Handle Dart_LoadScript(Dart_Handle url, | 5073 DART_EXPORT Dart_Handle Dart_LoadScript(Dart_Handle url, |
| 5070 Dart_Handle resolved_url, | 5074 Dart_Handle resolved_url, |
| 5071 Dart_Handle source, | 5075 Dart_Handle source, |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5229 | 5233 |
| 5230 Library& library = Library::Handle(Z, I->object_store()->root_library()); | 5234 Library& library = Library::Handle(Z, I->object_store()->root_library()); |
| 5231 if (!library.IsNull()) { | 5235 if (!library.IsNull()) { |
| 5232 const String& library_url = String::Handle(Z, library.url()); | 5236 const String& library_url = String::Handle(Z, library.url()); |
| 5233 return Api::NewError("%s: A script has already been loaded from '%s'.", | 5237 return Api::NewError("%s: A script has already been loaded from '%s'.", |
| 5234 CURRENT_FUNC, library_url.ToCString()); | 5238 CURRENT_FUNC, library_url.ToCString()); |
| 5235 } | 5239 } |
| 5236 CHECK_CALLBACK_STATE(T); | 5240 CHECK_CALLBACK_STATE(T); |
| 5237 CHECK_COMPILATION_ALLOWED(I); | 5241 CHECK_COMPILATION_ALLOWED(I); |
| 5238 | 5242 |
| 5239 // NOTE: Now the VM owns the [kernel_program] memory! Currently we do not | 5243 // NOTE: Now the VM owns the [kernel_program] memory! |
| 5240 // free it because (similar to the token stream) it will be used to repeatedly | 5244 // We will promptly delete it when done. |
| 5241 // run the `kernel::FlowGraphBuilder()`. | 5245 kernel::Program* program = reinterpret_cast<kernel::Program*>(kernel_program); |
| 5242 kernel::KernelReader reader( | 5246 kernel::KernelReader reader(program); |
| 5243 reinterpret_cast<kernel::Program*>(kernel_program)); | |
| 5244 const Object& tmp = reader.ReadProgram(); | 5247 const Object& tmp = reader.ReadProgram(); |
| 5248 delete program; | |
| 5249 program = NULL; | |
|
Kevin Millikin (Google)
2017/08/14 06:20:50
Likewise, here I don't think setting them to NULL
jensj
2017/08/14 08:38:12
Done.
| |
| 5250 kernel_program = NULL; | |
| 5251 | |
| 5245 if (tmp.IsError()) { | 5252 if (tmp.IsError()) { |
| 5246 return Api::NewHandle(T, tmp.raw()); | 5253 return Api::NewHandle(T, tmp.raw()); |
| 5247 } | 5254 } |
| 5248 // TODO(kernel): Setting root library based on whether it has 'main' or not | 5255 // TODO(kernel): Setting root library based on whether it has 'main' or not |
| 5249 // is not correct because main can be in the exported namespace of a library | 5256 // is not correct because main can be in the exported namespace of a library |
| 5250 // or it could be a getter. | 5257 // or it could be a getter. |
| 5251 if (tmp.IsNull()) { | 5258 if (tmp.IsNull()) { |
| 5252 return Api::NewError("%s: The binary program does not contain 'main'.", | 5259 return Api::NewError("%s: The binary program does not contain 'main'.", |
| 5253 CURRENT_FUNC); | 5260 CURRENT_FUNC); |
| 5254 } | 5261 } |
| (...skipping 1484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6739 #endif | 6746 #endif |
| 6740 } | 6747 } |
| 6741 | 6748 |
| 6742 DART_EXPORT void Dart_DumpNativeStackTrace(void* context) { | 6749 DART_EXPORT void Dart_DumpNativeStackTrace(void* context) { |
| 6743 #ifndef PRODUCT | 6750 #ifndef PRODUCT |
| 6744 Profiler::DumpStackTrace(context); | 6751 Profiler::DumpStackTrace(context); |
| 6745 #endif | 6752 #endif |
| 6746 } | 6753 } |
| 6747 | 6754 |
| 6748 } // namespace dart | 6755 } // namespace dart |
| OLD | NEW |