| OLD | NEW |
| 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/v8.h" | 5 #include "src/v8.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.h" | 10 #include "src/frames.h" |
| 11 #include "src/full-codegen.h" | 11 #include "src/full-codegen.h" |
| 12 #include "src/isolate-inl.h" | 12 #include "src/isolate-inl.h" |
| 13 #include "src/messages.h" |
| 13 #include "src/runtime/runtime-utils.h" | 14 #include "src/runtime/runtime-utils.h" |
| 14 #include "src/v8threads.h" | 15 #include "src/v8threads.h" |
| 15 #include "src/vm-state-inl.h" | 16 #include "src/vm-state-inl.h" |
| 16 | 17 |
| 17 namespace v8 { | 18 namespace v8 { |
| 18 namespace internal { | 19 namespace internal { |
| 19 | 20 |
| 20 RUNTIME_FUNCTION(Runtime_CompileLazy) { | 21 RUNTIME_FUNCTION(Runtime_CompileLazy) { |
| 21 HandleScope scope(isolate); | 22 HandleScope scope(isolate); |
| 22 DCHECK(args.length() == 1); | 23 DCHECK(args.length() == 1); |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 // Extract native context. | 358 // Extract native context. |
| 358 Handle<Context> context(isolate->native_context()); | 359 Handle<Context> context(isolate->native_context()); |
| 359 | 360 |
| 360 // Check if native context allows code generation from | 361 // Check if native context allows code generation from |
| 361 // strings. Throw an exception if it doesn't. | 362 // strings. Throw an exception if it doesn't. |
| 362 if (context->allow_code_gen_from_strings()->IsFalse() && | 363 if (context->allow_code_gen_from_strings()->IsFalse() && |
| 363 !CodeGenerationFromStringsAllowed(isolate, context)) { | 364 !CodeGenerationFromStringsAllowed(isolate, context)) { |
| 364 Handle<Object> error_message = | 365 Handle<Object> error_message = |
| 365 context->ErrorMessageForCodeGenerationFromStrings(); | 366 context->ErrorMessageForCodeGenerationFromStrings(); |
| 366 THROW_NEW_ERROR_RETURN_FAILURE( | 367 THROW_NEW_ERROR_RETURN_FAILURE( |
| 367 isolate, NewEvalError("code_gen_from_strings", | 368 isolate, |
| 368 HandleVector<Object>(&error_message, 1))); | 369 NewEvalError(MessageTemplate::kCodeGenFromStrings, error_message)); |
| 369 } | 370 } |
| 370 | 371 |
| 371 // Compile source string in the native context. | 372 // Compile source string in the native context. |
| 372 ParseRestriction restriction = function_literal_only | 373 ParseRestriction restriction = function_literal_only |
| 373 ? ONLY_SINGLE_FUNCTION_LITERAL | 374 ? ONLY_SINGLE_FUNCTION_LITERAL |
| 374 : NO_PARSE_RESTRICTION; | 375 : NO_PARSE_RESTRICTION; |
| 375 Handle<SharedFunctionInfo> outer_info(context->closure()->shared(), isolate); | 376 Handle<SharedFunctionInfo> outer_info(context->closure()->shared(), isolate); |
| 376 Handle<JSFunction> fun; | 377 Handle<JSFunction> fun; |
| 377 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 378 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 378 isolate, fun, | 379 isolate, fun, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 391 Handle<Context> native_context = Handle<Context>(context->native_context()); | 392 Handle<Context> native_context = Handle<Context>(context->native_context()); |
| 392 | 393 |
| 393 // Check if native context allows code generation from | 394 // Check if native context allows code generation from |
| 394 // strings. Throw an exception if it doesn't. | 395 // strings. Throw an exception if it doesn't. |
| 395 if (native_context->allow_code_gen_from_strings()->IsFalse() && | 396 if (native_context->allow_code_gen_from_strings()->IsFalse() && |
| 396 !CodeGenerationFromStringsAllowed(isolate, native_context)) { | 397 !CodeGenerationFromStringsAllowed(isolate, native_context)) { |
| 397 Handle<Object> error_message = | 398 Handle<Object> error_message = |
| 398 native_context->ErrorMessageForCodeGenerationFromStrings(); | 399 native_context->ErrorMessageForCodeGenerationFromStrings(); |
| 399 Handle<Object> error; | 400 Handle<Object> error; |
| 400 MaybeHandle<Object> maybe_error = isolate->factory()->NewEvalError( | 401 MaybeHandle<Object> maybe_error = isolate->factory()->NewEvalError( |
| 401 "code_gen_from_strings", HandleVector<Object>(&error_message, 1)); | 402 MessageTemplate::kCodeGenFromStrings, error_message); |
| 402 if (maybe_error.ToHandle(&error)) isolate->Throw(*error); | 403 if (maybe_error.ToHandle(&error)) isolate->Throw(*error); |
| 403 return MakePair(isolate->heap()->exception(), NULL); | 404 return MakePair(isolate->heap()->exception(), NULL); |
| 404 } | 405 } |
| 405 | 406 |
| 406 // Deal with a normal eval call with a string argument. Compile it | 407 // Deal with a normal eval call with a string argument. Compile it |
| 407 // and return the compiled function bound in the local context. | 408 // and return the compiled function bound in the local context. |
| 408 static const ParseRestriction restriction = NO_PARSE_RESTRICTION; | 409 static const ParseRestriction restriction = NO_PARSE_RESTRICTION; |
| 409 Handle<JSFunction> compiled; | 410 Handle<JSFunction> compiled; |
| 410 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 411 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
| 411 isolate, compiled, | 412 isolate, compiled, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 436 DCHECK(is_valid_language_mode(args.smi_at(4))); | 437 DCHECK(is_valid_language_mode(args.smi_at(4))); |
| 437 LanguageMode language_mode = static_cast<LanguageMode>(args.smi_at(4)); | 438 LanguageMode language_mode = static_cast<LanguageMode>(args.smi_at(4)); |
| 438 DCHECK(args[5]->IsSmi()); | 439 DCHECK(args[5]->IsSmi()); |
| 439 Handle<SharedFunctionInfo> outer_info(args.at<JSFunction>(2)->shared(), | 440 Handle<SharedFunctionInfo> outer_info(args.at<JSFunction>(2)->shared(), |
| 440 isolate); | 441 isolate); |
| 441 return CompileGlobalEval(isolate, args.at<String>(1), outer_info, | 442 return CompileGlobalEval(isolate, args.at<String>(1), outer_info, |
| 442 args.at<Object>(3), language_mode, args.smi_at(5)); | 443 args.at<Object>(3), language_mode, args.smi_at(5)); |
| 443 } | 444 } |
| 444 } | 445 } |
| 445 } // namespace v8::internal | 446 } // namespace v8::internal |
| OLD | NEW |