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

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

Issue 1179893002: Add script context with context-allocated "const this" (Closed) Base URL: https://chromium.googlesource.com/v8/v8@master
Patch Set: Factor out Variable::HasThisName Created 5 years, 6 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/scopeinfo.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/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"
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 Handle<SharedFunctionInfo> outer_info(context->closure()->shared(), isolate); 374 Handle<SharedFunctionInfo> outer_info(context->closure()->shared(), isolate);
375 Handle<JSFunction> fun; 375 Handle<JSFunction> fun;
376 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 376 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
377 isolate, fun, 377 isolate, fun,
378 Compiler::GetFunctionFromEval(source, outer_info, context, SLOPPY, 378 Compiler::GetFunctionFromEval(source, outer_info, context, SLOPPY,
379 restriction, RelocInfo::kNoPosition)); 379 restriction, RelocInfo::kNoPosition));
380 return *fun; 380 return *fun;
381 } 381 }
382 382
383 383
384 static ObjectPair CompileGlobalEval(Isolate* isolate, Handle<String> source, 384 static Object* CompileGlobalEval(Isolate* isolate, Handle<String> source,
385 Handle<SharedFunctionInfo> outer_info, 385 Handle<SharedFunctionInfo> outer_info,
386 Handle<Object> receiver, 386 LanguageMode language_mode,
387 LanguageMode language_mode, 387 int scope_position) {
388 int scope_position) {
389 Handle<Context> context = Handle<Context>(isolate->context()); 388 Handle<Context> context = Handle<Context>(isolate->context());
390 Handle<Context> native_context = Handle<Context>(context->native_context()); 389 Handle<Context> native_context = Handle<Context>(context->native_context());
391 390
392 // Check if native context allows code generation from 391 // Check if native context allows code generation from
393 // strings. Throw an exception if it doesn't. 392 // strings. Throw an exception if it doesn't.
394 if (native_context->allow_code_gen_from_strings()->IsFalse() && 393 if (native_context->allow_code_gen_from_strings()->IsFalse() &&
395 !CodeGenerationFromStringsAllowed(isolate, native_context)) { 394 !CodeGenerationFromStringsAllowed(isolate, native_context)) {
396 Handle<Object> error_message = 395 Handle<Object> error_message =
397 native_context->ErrorMessageForCodeGenerationFromStrings(); 396 native_context->ErrorMessageForCodeGenerationFromStrings();
398 Handle<Object> error; 397 Handle<Object> error;
399 MaybeHandle<Object> maybe_error = isolate->factory()->NewEvalError( 398 MaybeHandle<Object> maybe_error = isolate->factory()->NewEvalError(
400 MessageTemplate::kCodeGenFromStrings, error_message); 399 MessageTemplate::kCodeGenFromStrings, error_message);
401 if (maybe_error.ToHandle(&error)) isolate->Throw(*error); 400 if (maybe_error.ToHandle(&error)) isolate->Throw(*error);
402 return MakePair(isolate->heap()->exception(), NULL); 401 return isolate->heap()->exception();
403 } 402 }
404 403
405 // Deal with a normal eval call with a string argument. Compile it 404 // Deal with a normal eval call with a string argument. Compile it
406 // and return the compiled function bound in the local context. 405 // and return the compiled function bound in the local context.
407 static const ParseRestriction restriction = NO_PARSE_RESTRICTION; 406 static const ParseRestriction restriction = NO_PARSE_RESTRICTION;
408 Handle<JSFunction> compiled; 407 Handle<JSFunction> compiled;
409 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 408 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
410 isolate, compiled, 409 isolate, compiled,
411 Compiler::GetFunctionFromEval(source, outer_info, context, language_mode, 410 Compiler::GetFunctionFromEval(source, outer_info, context, language_mode,
412 restriction, scope_position), 411 restriction, scope_position),
413 MakePair(isolate->heap()->exception(), NULL)); 412 isolate->heap()->exception());
414 return MakePair(*compiled, *receiver); 413 return *compiled;
415 } 414 }
416 415
417 416
418 RUNTIME_FUNCTION_RETURN_PAIR(Runtime_ResolvePossiblyDirectEval) { 417 RUNTIME_FUNCTION(Runtime_ResolvePossiblyDirectEval) {
419 HandleScope scope(isolate); 418 HandleScope scope(isolate);
420 DCHECK(args.length() == 6); 419 DCHECK(args.length() == 5);
421 420
422 Handle<Object> callee = args.at<Object>(0); 421 Handle<Object> callee = args.at<Object>(0);
423 422
424 // If "eval" didn't refer to the original GlobalEval, it's not a 423 // If "eval" didn't refer to the original GlobalEval, it's not a
425 // direct call to eval. 424 // direct call to eval.
426 // (And even if it is, but the first argument isn't a string, just let 425 // (And even if it is, but the first argument isn't a string, just let
427 // execution default to an indirect call to eval, which will also return 426 // execution default to an indirect call to eval, which will also return
428 // the first argument without doing anything). 427 // the first argument without doing anything).
429 if (*callee != isolate->native_context()->global_eval_fun() || 428 if (*callee != isolate->native_context()->global_eval_fun() ||
430 !args[1]->IsString()) { 429 !args[1]->IsString()) {
431 return MakePair(*callee, isolate->heap()->undefined_value()); 430 return *callee;
432 } 431 }
433 432
433 DCHECK(args[3]->IsSmi());
434 DCHECK(is_valid_language_mode(args.smi_at(3)));
435 LanguageMode language_mode = static_cast<LanguageMode>(args.smi_at(3));
434 DCHECK(args[4]->IsSmi()); 436 DCHECK(args[4]->IsSmi());
435 DCHECK(is_valid_language_mode(args.smi_at(4)));
436 LanguageMode language_mode = static_cast<LanguageMode>(args.smi_at(4));
437 DCHECK(args[5]->IsSmi());
438 Handle<SharedFunctionInfo> outer_info(args.at<JSFunction>(2)->shared(), 437 Handle<SharedFunctionInfo> outer_info(args.at<JSFunction>(2)->shared(),
439 isolate); 438 isolate);
440 return CompileGlobalEval(isolate, args.at<String>(1), outer_info, 439 return CompileGlobalEval(isolate, args.at<String>(1), outer_info,
441 args.at<Object>(3), language_mode, args.smi_at(5)); 440 language_mode, args.smi_at(4));
442 } 441 }
443 } // namespace internal 442 } // namespace internal
444 } // namespace v8 443 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | src/scopeinfo.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698