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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/ast.h" | 7 #include "src/ast.h" |
8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
10 #include "src/ic/ic.h" | 10 #include "src/ic/ic.h" |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 // Check if the constructor directly references a foreign context. | 431 // Check if the constructor directly references a foreign context. |
432 if (CanRetainOtherContext(JSFunction::cast(constructor), | 432 if (CanRetainOtherContext(JSFunction::cast(constructor), |
433 native_context)) { | 433 native_context)) { |
434 return true; | 434 return true; |
435 } | 435 } |
436 } | 436 } |
437 map = HeapObject::cast(map->prototype())->map(); | 437 map = HeapObject::cast(map->prototype())->map(); |
438 } | 438 } |
439 constructor = map->GetConstructor(); | 439 constructor = map->GetConstructor(); |
440 if (constructor->IsNull()) return false; | 440 if (constructor->IsNull()) return false; |
| 441 // If the constructor is not null or a JSFunction, we have to conservatively |
| 442 // assume that it may retain a native context. |
| 443 if (!constructor->IsJSFunction()) return true; |
441 JSFunction* function = JSFunction::cast(constructor); | 444 JSFunction* function = JSFunction::cast(constructor); |
442 return CanRetainOtherContext(function, native_context); | 445 return CanRetainOtherContext(function, native_context); |
443 } | 446 } |
444 | 447 |
445 | 448 |
446 bool TypeFeedbackOracle::CanRetainOtherContext(JSFunction* function, | 449 bool TypeFeedbackOracle::CanRetainOtherContext(JSFunction* function, |
447 Context* native_context) { | 450 Context* native_context) { |
448 return function->context()->global_object() != native_context->global_object() | 451 return function->context()->global_object() != native_context->global_object() |
449 && function->context()->global_object() != native_context->builtins(); | 452 && function->context()->global_object() != native_context->builtins(); |
450 } | 453 } |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 UnseededNumberDictionary::kNotFound); | 566 UnseededNumberDictionary::kNotFound); |
564 // Dictionary has been allocated with sufficient size for all elements. | 567 // Dictionary has been allocated with sufficient size for all elements. |
565 DisallowHeapAllocation no_need_to_resize_dictionary; | 568 DisallowHeapAllocation no_need_to_resize_dictionary; |
566 HandleScope scope(isolate()); | 569 HandleScope scope(isolate()); |
567 USE(UnseededNumberDictionary::AtNumberPut( | 570 USE(UnseededNumberDictionary::AtNumberPut( |
568 dictionary_, IdToKey(ast_id), handle(target, isolate()))); | 571 dictionary_, IdToKey(ast_id), handle(target, isolate()))); |
569 } | 572 } |
570 | 573 |
571 | 574 |
572 } } // namespace v8::internal | 575 } } // namespace v8::internal |
OLD | NEW |