| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 9082 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9093 ASSERT_EQ(1, args.length()); | 9093 ASSERT_EQ(1, args.length()); |
| 9094 CONVERT_ARG_HANDLE_CHECKED(String, source, 0); | 9094 CONVERT_ARG_HANDLE_CHECKED(String, source, 0); |
| 9095 | 9095 |
| 9096 // Extract native context. | 9096 // Extract native context. |
| 9097 Handle<Context> context(isolate->context()->native_context()); | 9097 Handle<Context> context(isolate->context()->native_context()); |
| 9098 | 9098 |
| 9099 // Check if native context allows code generation from | 9099 // Check if native context allows code generation from |
| 9100 // strings. Throw an exception if it doesn't. | 9100 // strings. Throw an exception if it doesn't. |
| 9101 if (context->allow_code_gen_from_strings()->IsFalse() && | 9101 if (context->allow_code_gen_from_strings()->IsFalse() && |
| 9102 !CodeGenerationFromStringsAllowed(isolate, context)) { | 9102 !CodeGenerationFromStringsAllowed(isolate, context)) { |
| 9103 return isolate->Throw(*isolate->factory()->NewError( | 9103 Handle<Object> error_message = |
| 9104 "code_gen_from_strings", HandleVector<Object>(NULL, 0))); | 9104 context->ErrorMessageForCodeGenerationFromStrings(); |
| 9105 return isolate->Throw(*isolate->factory()->NewEvalError( |
| 9106 "code_gen_from_strings", HandleVector<Object>(&error_message, 1))); |
| 9105 } | 9107 } |
| 9106 | 9108 |
| 9107 // Compile source string in the native context. | 9109 // Compile source string in the native context. |
| 9108 Handle<SharedFunctionInfo> shared = Compiler::CompileEval( | 9110 Handle<SharedFunctionInfo> shared = Compiler::CompileEval( |
| 9109 source, context, true, CLASSIC_MODE, RelocInfo::kNoPosition); | 9111 source, context, true, CLASSIC_MODE, RelocInfo::kNoPosition); |
| 9110 if (shared.is_null()) return Failure::Exception(); | 9112 if (shared.is_null()) return Failure::Exception(); |
| 9111 Handle<JSFunction> fun = | 9113 Handle<JSFunction> fun = |
| 9112 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, | 9114 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, |
| 9113 context, | 9115 context, |
| 9114 NOT_TENURED); | 9116 NOT_TENURED); |
| 9115 return *fun; | 9117 return *fun; |
| 9116 } | 9118 } |
| 9117 | 9119 |
| 9118 | 9120 |
| 9119 static ObjectPair CompileGlobalEval(Isolate* isolate, | 9121 static ObjectPair CompileGlobalEval(Isolate* isolate, |
| 9120 Handle<String> source, | 9122 Handle<String> source, |
| 9121 Handle<Object> receiver, | 9123 Handle<Object> receiver, |
| 9122 LanguageMode language_mode, | 9124 LanguageMode language_mode, |
| 9123 int scope_position) { | 9125 int scope_position) { |
| 9124 Handle<Context> context = Handle<Context>(isolate->context()); | 9126 Handle<Context> context = Handle<Context>(isolate->context()); |
| 9125 Handle<Context> native_context = Handle<Context>(context->native_context()); | 9127 Handle<Context> native_context = Handle<Context>(context->native_context()); |
| 9126 | 9128 |
| 9127 // Check if native context allows code generation from | 9129 // Check if native context allows code generation from |
| 9128 // strings. Throw an exception if it doesn't. | 9130 // strings. Throw an exception if it doesn't. |
| 9129 if (native_context->allow_code_gen_from_strings()->IsFalse() && | 9131 if (native_context->allow_code_gen_from_strings()->IsFalse() && |
| 9130 !CodeGenerationFromStringsAllowed(isolate, native_context)) { | 9132 !CodeGenerationFromStringsAllowed(isolate, native_context)) { |
| 9131 isolate->Throw(*isolate->factory()->NewError( | 9133 Handle<Object> error_message = |
| 9132 "code_gen_from_strings", HandleVector<Object>(NULL, 0))); | 9134 context->ErrorMessageForCodeGenerationFromStrings(); |
| 9135 isolate->Throw(*isolate->factory()->NewEvalError( |
| 9136 "code_gen_from_strings", HandleVector<Object>(&error_message, 1))); |
| 9133 return MakePair(Failure::Exception(), NULL); | 9137 return MakePair(Failure::Exception(), NULL); |
| 9134 } | 9138 } |
| 9135 | 9139 |
| 9136 // Deal with a normal eval call with a string argument. Compile it | 9140 // Deal with a normal eval call with a string argument. Compile it |
| 9137 // and return the compiled function bound in the local context. | 9141 // and return the compiled function bound in the local context. |
| 9138 Handle<SharedFunctionInfo> shared = Compiler::CompileEval( | 9142 Handle<SharedFunctionInfo> shared = Compiler::CompileEval( |
| 9139 source, | 9143 source, |
| 9140 Handle<Context>(isolate->context()), | 9144 Handle<Context>(isolate->context()), |
| 9141 context->IsNativeContext(), | 9145 context->IsNativeContext(), |
| 9142 language_mode, | 9146 language_mode, |
| (...skipping 4253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13396 // Handle last resort GC and make sure to allow future allocations | 13400 // Handle last resort GC and make sure to allow future allocations |
| 13397 // to grow the heap without causing GCs (if possible). | 13401 // to grow the heap without causing GCs (if possible). |
| 13398 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13402 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 13399 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13403 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
| 13400 "Runtime::PerformGC"); | 13404 "Runtime::PerformGC"); |
| 13401 } | 13405 } |
| 13402 } | 13406 } |
| 13403 | 13407 |
| 13404 | 13408 |
| 13405 } } // namespace v8::internal | 13409 } } // namespace v8::internal |
| OLD | NEW |