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/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/arguments.h" | 8 #include "src/arguments.h" |
9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
10 #include "src/cpu-profiler.h" | 10 #include "src/cpu-profiler.h" |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 // Set the code of the target function. | 288 // Set the code of the target function. |
289 target->ReplaceCode(source_shared->code()); | 289 target->ReplaceCode(source_shared->code()); |
290 DCHECK(target->next_function_link()->IsUndefined()); | 290 DCHECK(target->next_function_link()->IsUndefined()); |
291 | 291 |
292 // Make sure we get a fresh copy of the literal vector to avoid cross | 292 // Make sure we get a fresh copy of the literal vector to avoid cross |
293 // context contamination. | 293 // context contamination. |
294 Handle<Context> context(source->context()); | 294 Handle<Context> context(source->context()); |
295 int number_of_literals = source->NumberOfLiterals(); | 295 int number_of_literals = source->NumberOfLiterals(); |
296 Handle<FixedArray> literals = | 296 Handle<FixedArray> literals = |
297 isolate->factory()->NewFixedArray(number_of_literals, TENURED); | 297 isolate->factory()->NewFixedArray(number_of_literals, TENURED); |
298 if (number_of_literals > 0) { | |
299 literals->set(JSFunction::kLiteralNativeContextIndex, | |
300 context->native_context()); | |
301 } | |
302 target->set_context(*context); | 298 target->set_context(*context); |
303 target->set_literals(*literals); | 299 target->set_literals(*literals); |
304 | 300 |
305 if (isolate->logger()->is_logging_code_events() || | 301 if (isolate->logger()->is_logging_code_events() || |
306 isolate->cpu_profiler()->is_profiling()) { | 302 isolate->cpu_profiler()->is_profiling()) { |
307 isolate->logger()->LogExistingFunction(source_shared, | 303 isolate->logger()->LogExistingFunction(source_shared, |
308 Handle<Code>(source_shared->code())); | 304 Handle<Code>(source_shared->code())); |
309 } | 305 } |
310 | 306 |
311 return *target; | 307 return *target; |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 | 642 |
647 | 643 |
648 RUNTIME_FUNCTION(RuntimeReference_IsFunction) { | 644 RUNTIME_FUNCTION(RuntimeReference_IsFunction) { |
649 SealHandleScope shs(isolate); | 645 SealHandleScope shs(isolate); |
650 DCHECK(args.length() == 1); | 646 DCHECK(args.length() == 1); |
651 CONVERT_ARG_CHECKED(Object, obj, 0); | 647 CONVERT_ARG_CHECKED(Object, obj, 0); |
652 return isolate->heap()->ToBoolean(obj->IsJSFunction()); | 648 return isolate->heap()->ToBoolean(obj->IsJSFunction()); |
653 } | 649 } |
654 } | 650 } |
655 } // namespace v8::internal | 651 } // namespace v8::internal |
OLD | NEW |