OLD | NEW |
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/builtins.h" | 5 #include "src/builtins.h" |
6 | 6 |
7 #include "src/api-arguments.h" | 7 #include "src/api-arguments.h" |
8 #include "src/api-natives.h" | 8 #include "src/api-natives.h" |
9 #include "src/api.h" | 9 #include "src/api.h" |
10 #include "src/base/once.h" | 10 #include "src/base/once.h" |
(...skipping 2049 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2060 if (native_context->allow_code_gen_from_strings()->IsFalse() && | 2060 if (native_context->allow_code_gen_from_strings()->IsFalse() && |
2061 !CodeGenerationFromStringsAllowed(isolate, native_context)) { | 2061 !CodeGenerationFromStringsAllowed(isolate, native_context)) { |
2062 Handle<Object> error_message = | 2062 Handle<Object> error_message = |
2063 native_context->ErrorMessageForCodeGenerationFromStrings(); | 2063 native_context->ErrorMessageForCodeGenerationFromStrings(); |
2064 THROW_NEW_ERROR(isolate, NewEvalError(MessageTemplate::kCodeGenFromStrings, | 2064 THROW_NEW_ERROR(isolate, NewEvalError(MessageTemplate::kCodeGenFromStrings, |
2065 error_message), | 2065 error_message), |
2066 JSFunction); | 2066 JSFunction); |
2067 } | 2067 } |
2068 | 2068 |
2069 // Compile source string in the native context. | 2069 // Compile source string in the native context. |
2070 Handle<SharedFunctionInfo> outer_info(native_context->closure()->shared(), | 2070 StackTraceFrameIterator it(isolate); |
2071 isolate); | 2071 int eval_scope_position = 0; |
| 2072 int eval_position = RelocInfo::kNoPosition; |
| 2073 Handle<SharedFunctionInfo> outer_info; |
| 2074 if (!it.done() && it.is_javascript()) { |
| 2075 FrameSummary summary = FrameSummary::GetFirst(it.javascript_frame()); |
| 2076 eval_position = |
| 2077 summary.abstract_code()->SourcePosition(summary.code_offset()); |
| 2078 outer_info = Handle<SharedFunctionInfo>(summary.function()->shared()); |
| 2079 } else { |
| 2080 outer_info = |
| 2081 Handle<SharedFunctionInfo>(native_context->closure()->shared()); |
| 2082 } |
2072 return Compiler::GetFunctionFromEval(source, outer_info, native_context, | 2083 return Compiler::GetFunctionFromEval(source, outer_info, native_context, |
2073 SLOPPY, restriction, | 2084 SLOPPY, restriction, eval_scope_position, |
2074 RelocInfo::kNoPosition); | 2085 eval_position); |
2075 } | 2086 } |
2076 | 2087 |
2077 } // namespace | 2088 } // namespace |
2078 | 2089 |
2079 | 2090 |
2080 // ES6 section 18.2.1 eval (x) | 2091 // ES6 section 18.2.1 eval (x) |
2081 BUILTIN(GlobalEval) { | 2092 BUILTIN(GlobalEval) { |
2082 HandleScope scope(isolate); | 2093 HandleScope scope(isolate); |
2083 Handle<Object> x = args.atOrUndefined(isolate, 1); | 2094 Handle<Object> x = args.atOrUndefined(isolate, 1); |
2084 Handle<JSFunction> target = args.target<JSFunction>(); | 2095 Handle<JSFunction> target = args.target<JSFunction>(); |
(...skipping 3214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5299 BUILTIN_LIST_T(DEFINE_BUILTIN_ACCESSOR_T) | 5310 BUILTIN_LIST_T(DEFINE_BUILTIN_ACCESSOR_T) |
5300 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) | 5311 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) |
5301 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 5312 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) |
5302 #undef DEFINE_BUILTIN_ACCESSOR_C | 5313 #undef DEFINE_BUILTIN_ACCESSOR_C |
5303 #undef DEFINE_BUILTIN_ACCESSOR_A | 5314 #undef DEFINE_BUILTIN_ACCESSOR_A |
5304 #undef DEFINE_BUILTIN_ACCESSOR_T | 5315 #undef DEFINE_BUILTIN_ACCESSOR_T |
5305 #undef DEFINE_BUILTIN_ACCESSOR_H | 5316 #undef DEFINE_BUILTIN_ACCESSOR_H |
5306 | 5317 |
5307 } // namespace internal | 5318 } // namespace internal |
5308 } // namespace v8 | 5319 } // namespace v8 |
OLD | NEW |