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/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/bootstrapper.h" | 8 #include "src/bootstrapper.h" |
9 #include "src/debug.h" | 9 #include "src/debug.h" |
10 #include "src/messages.h" | 10 #include "src/messages.h" |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 HandleScope scope(isolate); | 425 HandleScope scope(isolate); |
426 DCHECK(args.length() == 3); | 426 DCHECK(args.length() == 3); |
427 CONVERT_ARG_HANDLE_CHECKED(Context, script_context, 0); | 427 CONVERT_ARG_HANDLE_CHECKED(Context, script_context, 0); |
428 CONVERT_SMI_ARG_CHECKED(index, 1); | 428 CONVERT_SMI_ARG_CHECKED(index, 1); |
429 CONVERT_ARG_HANDLE_CHECKED(Name, name, 2); | 429 CONVERT_ARG_HANDLE_CHECKED(Name, name, 2); |
430 DCHECK(script_context->IsScriptContext()); | 430 DCHECK(script_context->IsScriptContext()); |
431 DCHECK(script_context->get(index)->IsPropertyCell()); | 431 DCHECK(script_context->get(index)->IsPropertyCell()); |
432 | 432 |
433 Handle<GlobalObject> global(script_context->global_object()); | 433 Handle<GlobalObject> global(script_context->global_object()); |
434 | 434 |
435 LookupIterator it(global, name, LookupIterator::OWN); | 435 LookupIterator it(global, name, LookupIterator::HIDDEN); |
436 if (LookupIterator::DATA == it.state()) { | 436 // Switch to fast mode only if there is a data property and it's not on |
| 437 // a hidden prototype. |
| 438 if (LookupIterator::DATA == it.state() && |
| 439 it.GetHolder<Object>()->IsJSGlobalObject()) { |
437 // Now update cell in the script context. | 440 // Now update cell in the script context. |
438 Handle<PropertyCell> cell = it.GetPropertyCell(); | 441 Handle<PropertyCell> cell = it.GetPropertyCell(); |
439 script_context->set(index, *cell); | 442 script_context->set(index, *cell); |
440 } else { | 443 } else { |
441 // This is not a fast case, so keep this access in a slow mode. | 444 // This is not a fast case, so keep this access in a slow mode. |
442 // Store empty_property_cell here to release the outdated property cell. | 445 // Store empty_property_cell here to release the outdated property cell. |
443 script_context->set(index, isolate->heap()->empty_property_cell()); | 446 script_context->set(index, isolate->heap()->empty_property_cell()); |
444 } | 447 } |
445 | 448 |
446 Handle<Object> result; | 449 Handle<Object> result; |
(...skipping 10 matching lines...) Expand all Loading... |
457 CONVERT_SMI_ARG_CHECKED(index, 1); | 460 CONVERT_SMI_ARG_CHECKED(index, 1); |
458 CONVERT_ARG_HANDLE_CHECKED(Name, name, 2); | 461 CONVERT_ARG_HANDLE_CHECKED(Name, name, 2); |
459 CONVERT_ARG_HANDLE_CHECKED(Object, value, 3); | 462 CONVERT_ARG_HANDLE_CHECKED(Object, value, 3); |
460 CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode_arg, 4); | 463 CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode_arg, 4); |
461 DCHECK(script_context->IsScriptContext()); | 464 DCHECK(script_context->IsScriptContext()); |
462 DCHECK(script_context->get(index)->IsPropertyCell()); | 465 DCHECK(script_context->get(index)->IsPropertyCell()); |
463 LanguageMode language_mode = language_mode_arg; | 466 LanguageMode language_mode = language_mode_arg; |
464 | 467 |
465 Handle<GlobalObject> global(script_context->global_object()); | 468 Handle<GlobalObject> global(script_context->global_object()); |
466 | 469 |
467 LookupIterator it(global, name, LookupIterator::OWN); | 470 LookupIterator it(global, name, LookupIterator::HIDDEN); |
468 if (LookupIterator::DATA == it.state()) { | 471 // Switch to fast mode only if there is a data property and it's not on |
| 472 // a hidden prototype. |
| 473 if (LookupIterator::DATA == it.state() && |
| 474 it.GetHolder<Object>()->IsJSGlobalObject()) { |
469 // Now update cell in the script context. | 475 // Now update cell in the script context. |
470 Handle<PropertyCell> cell = it.GetPropertyCell(); | 476 Handle<PropertyCell> cell = it.GetPropertyCell(); |
471 script_context->set(index, *cell); | 477 script_context->set(index, *cell); |
472 } else { | 478 } else { |
473 // This is not a fast case, so keep this access in a slow mode. | 479 // This is not a fast case, so keep this access in a slow mode. |
474 // Store empty_property_cell here to release the outdated property cell. | 480 // Store empty_property_cell here to release the outdated property cell. |
475 script_context->set(index, isolate->heap()->empty_property_cell()); | 481 script_context->set(index, isolate->heap()->empty_property_cell()); |
476 } | 482 } |
477 | 483 |
478 Handle<Object> result; | 484 Handle<Object> result; |
(...skipping 988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1467 CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3); | 1473 CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3); |
1468 | 1474 |
1469 RETURN_FAILURE_ON_EXCEPTION( | 1475 RETURN_FAILURE_ON_EXCEPTION( |
1470 isolate, | 1476 isolate, |
1471 JSObject::DefineAccessor(object, name, isolate->factory()->null_value(), | 1477 JSObject::DefineAccessor(object, name, isolate->factory()->null_value(), |
1472 setter, attrs)); | 1478 setter, attrs)); |
1473 return isolate->heap()->undefined_value(); | 1479 return isolate->heap()->undefined_value(); |
1474 } | 1480 } |
1475 } // namespace internal | 1481 } // namespace internal |
1476 } // namespace v8 | 1482 } // namespace v8 |
OLD | NEW |