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

Side by Side Diff: src/runtime/runtime-compiler.cc

Issue 1548623002: [runtime] Also migrate the Function and GeneratorFunction constructors to C++. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix message tests. Created 4 years, 12 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 | « src/runtime/runtime.h ('k') | src/runtime/runtime-function.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.h"
6 6
7 #include "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/compiler.h" 8 #include "src/compiler.h"
9 #include "src/deoptimizer.h" 9 #include "src/deoptimizer.h"
10 #include "src/frames-inl.h" 10 #include "src/frames-inl.h"
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 // No callback set and code generation disallowed. 359 // No callback set and code generation disallowed.
360 return false; 360 return false;
361 } else { 361 } else {
362 // Callback set. Let it decide if code generation is allowed. 362 // Callback set. Let it decide if code generation is allowed.
363 VMState<EXTERNAL> state(isolate); 363 VMState<EXTERNAL> state(isolate);
364 return callback(v8::Utils::ToLocal(context)); 364 return callback(v8::Utils::ToLocal(context));
365 } 365 }
366 } 366 }
367 367
368 368
369 RUNTIME_FUNCTION(Runtime_CompileString) {
370 HandleScope scope(isolate);
371 DCHECK(args.length() == 2);
372 CONVERT_ARG_HANDLE_CHECKED(String, source, 0);
373 CONVERT_BOOLEAN_ARG_CHECKED(function_literal_only, 1);
374
375 // Extract native context.
376 Handle<Context> context(isolate->native_context());
377
378 // Check if native context allows code generation from
379 // strings. Throw an exception if it doesn't.
380 if (context->allow_code_gen_from_strings()->IsFalse() &&
381 !CodeGenerationFromStringsAllowed(isolate, context)) {
382 Handle<Object> error_message =
383 context->ErrorMessageForCodeGenerationFromStrings();
384 THROW_NEW_ERROR_RETURN_FAILURE(
385 isolate,
386 NewEvalError(MessageTemplate::kCodeGenFromStrings, error_message));
387 }
388
389 // Compile source string in the native context.
390 ParseRestriction restriction = function_literal_only
391 ? ONLY_SINGLE_FUNCTION_LITERAL
392 : NO_PARSE_RESTRICTION;
393 Handle<SharedFunctionInfo> outer_info(context->closure()->shared(), isolate);
394 Handle<JSFunction> fun;
395 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
396 isolate, fun,
397 Compiler::GetFunctionFromEval(source, outer_info, context, SLOPPY,
398 restriction, RelocInfo::kNoPosition));
399 return *fun;
400 }
401
402
403 static Object* CompileGlobalEval(Isolate* isolate, Handle<String> source, 369 static Object* CompileGlobalEval(Isolate* isolate, Handle<String> source,
404 Handle<SharedFunctionInfo> outer_info, 370 Handle<SharedFunctionInfo> outer_info,
405 LanguageMode language_mode, 371 LanguageMode language_mode,
406 int scope_position) { 372 int scope_position) {
407 Handle<Context> context = Handle<Context>(isolate->context()); 373 Handle<Context> context = Handle<Context>(isolate->context());
408 Handle<Context> native_context = Handle<Context>(context->native_context()); 374 Handle<Context> native_context = Handle<Context>(context->native_context());
409 375
410 // Check if native context allows code generation from 376 // Check if native context allows code generation from
411 // strings. Throw an exception if it doesn't. 377 // strings. Throw an exception if it doesn't.
412 if (native_context->allow_code_gen_from_strings()->IsFalse() && 378 if (native_context->allow_code_gen_from_strings()->IsFalse() &&
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 DCHECK(is_valid_language_mode(args.smi_at(3))); 419 DCHECK(is_valid_language_mode(args.smi_at(3)));
454 LanguageMode language_mode = static_cast<LanguageMode>(args.smi_at(3)); 420 LanguageMode language_mode = static_cast<LanguageMode>(args.smi_at(3));
455 DCHECK(args[4]->IsSmi()); 421 DCHECK(args[4]->IsSmi());
456 Handle<SharedFunctionInfo> outer_info(args.at<JSFunction>(2)->shared(), 422 Handle<SharedFunctionInfo> outer_info(args.at<JSFunction>(2)->shared(),
457 isolate); 423 isolate);
458 return CompileGlobalEval(isolate, args.at<String>(1), outer_info, 424 return CompileGlobalEval(isolate, args.at<String>(1), outer_info,
459 language_mode, args.smi_at(4)); 425 language_mode, args.smi_at(4));
460 } 426 }
461 } // namespace internal 427 } // namespace internal
462 } // namespace v8 428 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | src/runtime/runtime-function.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698