Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(663)

Side by Side Diff: src/contexts.cc

Issue 2028983002: Introduce IsUndefined(Isolate*) and IsTheHole(Isolate*) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase master Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/pipeline.cc ('k') | src/contexts-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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/contexts.h" 5 #include "src/contexts.h"
6 6
7 #include "src/ast/scopeinfo.h" 7 #include "src/ast/scopeinfo.h"
8 #include "src/bootstrapper.h" 8 #include "src/bootstrapper.h"
9 #include "src/debug/debug.h" 9 #include "src/debug/debug.h"
10 #include "src/isolate-inl.h" 10 #include "src/isolate-inl.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 !current->IsNativeContext()) { 85 !current->IsNativeContext()) {
86 current = current->previous(); 86 current = current->previous();
87 DCHECK(current->closure() == closure()); 87 DCHECK(current->closure() == closure());
88 } 88 }
89 return current; 89 return current;
90 } 90 }
91 91
92 JSObject* Context::extension_object() { 92 JSObject* Context::extension_object() {
93 DCHECK(IsNativeContext() || IsFunctionContext() || IsBlockContext()); 93 DCHECK(IsNativeContext() || IsFunctionContext() || IsBlockContext());
94 HeapObject* object = extension(); 94 HeapObject* object = extension();
95 if (object->IsTheHole()) return nullptr; 95 if (object->IsTheHole(GetIsolate())) return nullptr;
96 if (IsBlockContext()) { 96 if (IsBlockContext()) {
97 if (!object->IsSloppyBlockWithEvalContextExtension()) return nullptr; 97 if (!object->IsSloppyBlockWithEvalContextExtension()) return nullptr;
98 object = SloppyBlockWithEvalContextExtension::cast(object)->extension(); 98 object = SloppyBlockWithEvalContextExtension::cast(object)->extension();
99 } 99 }
100 DCHECK(object->IsJSContextExtensionObject() || 100 DCHECK(object->IsJSContextExtensionObject() ||
101 (IsNativeContext() && object->IsJSGlobalObject())); 101 (IsNativeContext() && object->IsJSGlobalObject()));
102 return JSObject::cast(object); 102 return JSObject::cast(object);
103 } 103 }
104 104
105 105
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 int index = Context::MIN_CONTEXT_SLOTS + context_locals; 436 int index = Context::MIN_CONTEXT_SLOTS + context_locals;
437 for (int i = 0; i < context_globals; i++) { 437 for (int i = 0; i < context_globals; i++) {
438 set(index++, empty_cell); 438 set(index++, empty_cell);
439 } 439 }
440 } 440 }
441 } 441 }
442 442
443 443
444 void Context::AddOptimizedFunction(JSFunction* function) { 444 void Context::AddOptimizedFunction(JSFunction* function) {
445 DCHECK(IsNativeContext()); 445 DCHECK(IsNativeContext());
446 Isolate* isolate = GetIsolate();
446 #ifdef ENABLE_SLOW_DCHECKS 447 #ifdef ENABLE_SLOW_DCHECKS
447 if (FLAG_enable_slow_asserts) { 448 if (FLAG_enable_slow_asserts) {
448 Object* element = get(OPTIMIZED_FUNCTIONS_LIST); 449 Object* element = get(OPTIMIZED_FUNCTIONS_LIST);
449 while (!element->IsUndefined()) { 450 while (!element->IsUndefined(isolate)) {
450 CHECK(element != function); 451 CHECK(element != function);
451 element = JSFunction::cast(element)->next_function_link(); 452 element = JSFunction::cast(element)->next_function_link();
452 } 453 }
453 } 454 }
454 455
455 // Check that the context belongs to the weak native contexts list. 456 // Check that the context belongs to the weak native contexts list.
456 bool found = false; 457 bool found = false;
457 Object* context = GetHeap()->native_contexts_list(); 458 Object* context = isolate->heap()->native_contexts_list();
458 while (!context->IsUndefined()) { 459 while (!context->IsUndefined(isolate)) {
459 if (context == this) { 460 if (context == this) {
460 found = true; 461 found = true;
461 break; 462 break;
462 } 463 }
463 context = Context::cast(context)->next_context_link(); 464 context = Context::cast(context)->next_context_link();
464 } 465 }
465 CHECK(found); 466 CHECK(found);
466 #endif 467 #endif
467 468
468 // If the function link field is already used then the function was 469 // If the function link field is already used then the function was
469 // enqueued as a code flushing candidate and we remove it now. 470 // enqueued as a code flushing candidate and we remove it now.
470 if (!function->next_function_link()->IsUndefined()) { 471 if (!function->next_function_link()->IsUndefined(isolate)) {
471 CodeFlusher* flusher = GetHeap()->mark_compact_collector()->code_flusher(); 472 CodeFlusher* flusher = GetHeap()->mark_compact_collector()->code_flusher();
472 flusher->EvictCandidate(function); 473 flusher->EvictCandidate(function);
473 } 474 }
474 475
475 DCHECK(function->next_function_link()->IsUndefined()); 476 DCHECK(function->next_function_link()->IsUndefined(isolate));
476 477
477 function->set_next_function_link(get(OPTIMIZED_FUNCTIONS_LIST), 478 function->set_next_function_link(get(OPTIMIZED_FUNCTIONS_LIST),
478 UPDATE_WEAK_WRITE_BARRIER); 479 UPDATE_WEAK_WRITE_BARRIER);
479 set(OPTIMIZED_FUNCTIONS_LIST, function, UPDATE_WEAK_WRITE_BARRIER); 480 set(OPTIMIZED_FUNCTIONS_LIST, function, UPDATE_WEAK_WRITE_BARRIER);
480 } 481 }
481 482
482 483
483 void Context::RemoveOptimizedFunction(JSFunction* function) { 484 void Context::RemoveOptimizedFunction(JSFunction* function) {
484 DCHECK(IsNativeContext()); 485 DCHECK(IsNativeContext());
485 Object* element = get(OPTIMIZED_FUNCTIONS_LIST); 486 Object* element = get(OPTIMIZED_FUNCTIONS_LIST);
486 JSFunction* prev = NULL; 487 JSFunction* prev = NULL;
487 while (!element->IsUndefined()) { 488 Isolate* isolate = function->GetIsolate();
489 while (!element->IsUndefined(isolate)) {
488 JSFunction* element_function = JSFunction::cast(element); 490 JSFunction* element_function = JSFunction::cast(element);
489 DCHECK(element_function->next_function_link()->IsUndefined() || 491 DCHECK(element_function->next_function_link()->IsUndefined(isolate) ||
490 element_function->next_function_link()->IsJSFunction()); 492 element_function->next_function_link()->IsJSFunction());
491 if (element_function == function) { 493 if (element_function == function) {
492 if (prev == NULL) { 494 if (prev == NULL) {
493 set(OPTIMIZED_FUNCTIONS_LIST, element_function->next_function_link(), 495 set(OPTIMIZED_FUNCTIONS_LIST, element_function->next_function_link(),
494 UPDATE_WEAK_WRITE_BARRIER); 496 UPDATE_WEAK_WRITE_BARRIER);
495 } else { 497 } else {
496 prev->set_next_function_link(element_function->next_function_link(), 498 prev->set_next_function_link(element_function->next_function_link(),
497 UPDATE_WEAK_WRITE_BARRIER); 499 UPDATE_WEAK_WRITE_BARRIER);
498 } 500 }
499 element_function->set_next_function_link(GetHeap()->undefined_value(), 501 element_function->set_next_function_link(GetHeap()->undefined_value(),
(...skipping 15 matching lines...) Expand all
515 517
516 Object* Context::OptimizedFunctionsListHead() { 518 Object* Context::OptimizedFunctionsListHead() {
517 DCHECK(IsNativeContext()); 519 DCHECK(IsNativeContext());
518 return get(OPTIMIZED_FUNCTIONS_LIST); 520 return get(OPTIMIZED_FUNCTIONS_LIST);
519 } 521 }
520 522
521 523
522 void Context::AddOptimizedCode(Code* code) { 524 void Context::AddOptimizedCode(Code* code) {
523 DCHECK(IsNativeContext()); 525 DCHECK(IsNativeContext());
524 DCHECK(code->kind() == Code::OPTIMIZED_FUNCTION); 526 DCHECK(code->kind() == Code::OPTIMIZED_FUNCTION);
525 DCHECK(code->next_code_link()->IsUndefined()); 527 DCHECK(code->next_code_link()->IsUndefined(GetIsolate()));
526 code->set_next_code_link(get(OPTIMIZED_CODE_LIST)); 528 code->set_next_code_link(get(OPTIMIZED_CODE_LIST));
527 set(OPTIMIZED_CODE_LIST, code, UPDATE_WEAK_WRITE_BARRIER); 529 set(OPTIMIZED_CODE_LIST, code, UPDATE_WEAK_WRITE_BARRIER);
528 } 530 }
529 531
530 532
531 void Context::SetOptimizedCodeListHead(Object* head) { 533 void Context::SetOptimizedCodeListHead(Object* head) {
532 DCHECK(IsNativeContext()); 534 DCHECK(IsNativeContext());
533 set(OPTIMIZED_CODE_LIST, head, UPDATE_WEAK_WRITE_BARRIER); 535 set(OPTIMIZED_CODE_LIST, head, UPDATE_WEAK_WRITE_BARRIER);
534 } 536 }
535 537
(...skipping 12 matching lines...) Expand all
548 550
549 Object* Context::DeoptimizedCodeListHead() { 551 Object* Context::DeoptimizedCodeListHead() {
550 DCHECK(IsNativeContext()); 552 DCHECK(IsNativeContext());
551 return get(DEOPTIMIZED_CODE_LIST); 553 return get(DEOPTIMIZED_CODE_LIST);
552 } 554 }
553 555
554 556
555 Handle<Object> Context::ErrorMessageForCodeGenerationFromStrings() { 557 Handle<Object> Context::ErrorMessageForCodeGenerationFromStrings() {
556 Isolate* isolate = GetIsolate(); 558 Isolate* isolate = GetIsolate();
557 Handle<Object> result(error_message_for_code_gen_from_strings(), isolate); 559 Handle<Object> result(error_message_for_code_gen_from_strings(), isolate);
558 if (!result->IsUndefined()) return result; 560 if (!result->IsUndefined(isolate)) return result;
559 return isolate->factory()->NewStringFromStaticChars( 561 return isolate->factory()->NewStringFromStaticChars(
560 "Code generation from strings disallowed for this context"); 562 "Code generation from strings disallowed for this context");
561 } 563 }
562 564
563 565
564 #define COMPARE_NAME(index, type, name) \ 566 #define COMPARE_NAME(index, type, name) \
565 if (string->IsOneByteEqualTo(STATIC_CHAR_VECTOR(#name))) return index; 567 if (string->IsOneByteEqualTo(STATIC_CHAR_VECTOR(#name))) return index;
566 568
567 int Context::ImportedFieldIndexForName(Handle<String> string) { 569 int Context::ImportedFieldIndexForName(Handle<String> string) {
568 NATIVE_CONTEXT_IMPORTED_FIELDS(COMPARE_NAME) 570 NATIVE_CONTEXT_IMPORTED_FIELDS(COMPARE_NAME)
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 609
608 int previous_value = errors_thrown()->value(); 610 int previous_value = errors_thrown()->value();
609 set_errors_thrown(Smi::FromInt(previous_value + 1)); 611 set_errors_thrown(Smi::FromInt(previous_value + 1));
610 } 612 }
611 613
612 614
613 int Context::GetErrorsThrown() { return errors_thrown()->value(); } 615 int Context::GetErrorsThrown() { return errors_thrown()->value(); }
614 616
615 } // namespace internal 617 } // namespace internal
616 } // namespace v8 618 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/pipeline.cc ('k') | src/contexts-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698