diff --git a/deps/v8/src/runtime/runtime-compiler.cc b/deps/v8/src/runtime/runtime-compiler.cc index b5910e4..6c7bf13 100644 --- a/deps/v8/src/runtime/runtime-compiler.cc +++ b/deps/v8/src/runtime/runtime-compiler.cc @@ -395,10 +395,54 @@ bool CodeGenerationFromStringsAllowed(Isolate* isolate, } } -static Object* CompileGlobalEval(Isolate* isolate, Handle source, +static Object* CompileGlobalEval(Isolate* isolate, Handle old_source, Handle outer_info, LanguageMode language_mode, int eval_scope_position, int eval_position) { + /* The eval patch is MIT licensed. The text of the license follows. + +Copyright (c) 2016 @CapacitorSet + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + */ + + Handle source; + + std::stringstream temp_ostream; + (**old_source).PrintUC16(temp_ostream); + std::string source_string = temp_ostream.str(); + + std::string trigger_string("/* __eval_hook_skip */"); + if (source_string.find(trigger_string) == std::string::npos) { + std::stringstream patched_stream; + patched_stream << "/* Patched in deps/v8/src/runtime/runtime-compiler.cc */ /* __eval_hook_skip */ __eval_trap(`" << source_string << "`);"; + + std::string patched_string = patched_stream.str(); + const char* patched_cstr = patched_string.c_str(); + + Factory* factory = isolate->factory(); + source = factory->InternalizeUtf8String(patched_cstr); + } else { + source = old_source; + } + Handle context = Handle(isolate->context()); Handle native_context = Handle(context->native_context());