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

Side by Side Diff: src/api.cc

Issue 2695713014: [api] Use CHECK instead of DCHECK for IsModule tests in ScriptCompiler (Closed)
Patch Set: Fix build Created 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/api.h" 5 #include "src/api.h"
6 6
7 #include <string.h> // For memcpy, strlen. 7 #include <string.h> // For memcpy, strlen.
8 #ifdef V8_USE_ADDRESS_SANITIZER 8 #ifdef V8_USE_ADDRESS_SANITIZER
9 #include <sanitizer/asan_interface.h> 9 #include <sanitizer/asan_interface.h>
10 #endif // V8_USE_ADDRESS_SANITIZER 10 #endif // V8_USE_ADDRESS_SANITIZER
(...skipping 2160 matching lines...) Expand 10 before | Expand all | Expand 10 after
2171 source->cached_data->rejected = script_data->rejected(); 2171 source->cached_data->rejected = script_data->rejected();
2172 } 2172 }
2173 delete script_data; 2173 delete script_data;
2174 } 2174 }
2175 RETURN_ESCAPED(ToApiHandle<UnboundScript>(result)); 2175 RETURN_ESCAPED(ToApiHandle<UnboundScript>(result));
2176 } 2176 }
2177 2177
2178 2178
2179 MaybeLocal<UnboundScript> ScriptCompiler::CompileUnboundScript( 2179 MaybeLocal<UnboundScript> ScriptCompiler::CompileUnboundScript(
2180 Isolate* v8_isolate, Source* source, CompileOptions options) { 2180 Isolate* v8_isolate, Source* source, CompileOptions options) {
2181 DCHECK(!source->GetResourceOptions().IsModule()); 2181 Utils::ApiCheck(
2182 !source->GetResourceOptions().IsModule(),
2183 "v8::ScriptCompiler::CompileUnboundScript",
2184 "v8::ScriptCompiler::CompileModule must be used to compile modules");
2182 return CompileUnboundInternal(v8_isolate, source, options); 2185 return CompileUnboundInternal(v8_isolate, source, options);
2183 } 2186 }
2184 2187
2185 2188
2186 Local<UnboundScript> ScriptCompiler::CompileUnbound(Isolate* v8_isolate, 2189 Local<UnboundScript> ScriptCompiler::CompileUnbound(Isolate* v8_isolate,
2187 Source* source, 2190 Source* source,
2188 CompileOptions options) { 2191 CompileOptions options) {
2189 DCHECK(!source->GetResourceOptions().IsModule()); 2192 Utils::ApiCheck(
2193 !source->GetResourceOptions().IsModule(),
2194 "v8::ScriptCompiler::CompileUnbound",
2195 "v8::ScriptCompiler::CompileModule must be used to compile modules");
2190 RETURN_TO_LOCAL_UNCHECKED(CompileUnboundInternal(v8_isolate, source, options), 2196 RETURN_TO_LOCAL_UNCHECKED(CompileUnboundInternal(v8_isolate, source, options),
2191 UnboundScript); 2197 UnboundScript);
2192 } 2198 }
2193 2199
2194 2200
2195 MaybeLocal<Script> ScriptCompiler::Compile(Local<Context> context, 2201 MaybeLocal<Script> ScriptCompiler::Compile(Local<Context> context,
2196 Source* source, 2202 Source* source,
2197 CompileOptions options) { 2203 CompileOptions options) {
2198 DCHECK(!source->GetResourceOptions().IsModule()); 2204 Utils::ApiCheck(
2205 !source->GetResourceOptions().IsModule(), "v8::ScriptCompiler::Compile",
2206 "v8::ScriptCompiler::CompileModule must be used to compile modules");
2199 auto isolate = context->GetIsolate(); 2207 auto isolate = context->GetIsolate();
2200 auto maybe = CompileUnboundInternal(isolate, source, options); 2208 auto maybe = CompileUnboundInternal(isolate, source, options);
2201 Local<UnboundScript> result; 2209 Local<UnboundScript> result;
2202 if (!maybe.ToLocal(&result)) return MaybeLocal<Script>(); 2210 if (!maybe.ToLocal(&result)) return MaybeLocal<Script>();
2203 v8::Context::Scope scope(context); 2211 v8::Context::Scope scope(context);
2204 return result->BindToCurrentContext(); 2212 return result->BindToCurrentContext();
2205 } 2213 }
2206 2214
2207 2215
2208 Local<Script> ScriptCompiler::Compile( 2216 Local<Script> ScriptCompiler::Compile(
2209 Isolate* v8_isolate, 2217 Isolate* v8_isolate,
2210 Source* source, 2218 Source* source,
2211 CompileOptions options) { 2219 CompileOptions options) {
2212 auto context = v8_isolate->GetCurrentContext(); 2220 auto context = v8_isolate->GetCurrentContext();
2213 RETURN_TO_LOCAL_UNCHECKED(Compile(context, source, options), Script); 2221 RETURN_TO_LOCAL_UNCHECKED(Compile(context, source, options), Script);
2214 } 2222 }
2215 2223
2216 MaybeLocal<Module> ScriptCompiler::CompileModule(Isolate* isolate, 2224 MaybeLocal<Module> ScriptCompiler::CompileModule(Isolate* isolate,
2217 Source* source) { 2225 Source* source) {
2218 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 2226 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
2219 2227
2220 DCHECK(source->GetResourceOptions().IsModule()); 2228 Utils::ApiCheck(source->GetResourceOptions().IsModule(),
2229 "v8::ScriptCompiler::CompileModule",
2230 "Invalid ScriptOrigin: is_module must be true");
2221 auto maybe = CompileUnboundInternal(isolate, source, kNoCompileOptions); 2231 auto maybe = CompileUnboundInternal(isolate, source, kNoCompileOptions);
2222 Local<UnboundScript> unbound; 2232 Local<UnboundScript> unbound;
2223 if (!maybe.ToLocal(&unbound)) return MaybeLocal<Module>(); 2233 if (!maybe.ToLocal(&unbound)) return MaybeLocal<Module>();
2224 2234
2225 i::Handle<i::SharedFunctionInfo> shared = Utils::OpenHandle(*unbound); 2235 i::Handle<i::SharedFunctionInfo> shared = Utils::OpenHandle(*unbound);
2226 return ToApiHandle<Module>(i_isolate->factory()->NewModule(shared)); 2236 return ToApiHandle<Module>(i_isolate->factory()->NewModule(shared));
2227 } 2237 }
2228 2238
2229 2239
2230 class IsIdentifierHelper { 2240 class IsIdentifierHelper {
(...skipping 7938 matching lines...) Expand 10 before | Expand all | Expand 10 after
10169 Address callback_address = 10179 Address callback_address =
10170 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 10180 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
10171 VMState<EXTERNAL> state(isolate); 10181 VMState<EXTERNAL> state(isolate);
10172 ExternalCallbackScope call_scope(isolate, callback_address); 10182 ExternalCallbackScope call_scope(isolate, callback_address);
10173 callback(info); 10183 callback(info);
10174 } 10184 }
10175 10185
10176 10186
10177 } // namespace internal 10187 } // namespace internal
10178 } // namespace v8 10188 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698