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

Side by Side Diff: src/objects.cc

Issue 2915793002: [api] Prototype WeakRef implementation
Patch Set: Created 3 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/objects.h ('k') | src/objects-body-descriptors-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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/objects.h" 5 #include "src/objects.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <iomanip> 8 #include <iomanip>
9 #include <memory> 9 #include <memory>
10 #include <sstream> 10 #include <sstream>
(...skipping 2679 matching lines...) Expand 10 before | Expand all | Expand 10 after
2690 break; 2690 break;
2691 } 2691 }
2692 case JS_WEAK_MAP_TYPE: { 2692 case JS_WEAK_MAP_TYPE: {
2693 accumulator->Add("<JSWeakMap>"); 2693 accumulator->Add("<JSWeakMap>");
2694 break; 2694 break;
2695 } 2695 }
2696 case JS_WEAK_SET_TYPE: { 2696 case JS_WEAK_SET_TYPE: {
2697 accumulator->Add("<JSWeakSet>"); 2697 accumulator->Add("<JSWeakSet>");
2698 break; 2698 break;
2699 } 2699 }
2700 case JS_WEAK_REF_TYPE: {
2701 accumulator->Add("<JSWeakRef>");
2702 break;
2703 }
2700 case JS_REGEXP_TYPE: { 2704 case JS_REGEXP_TYPE: {
2701 accumulator->Add("<JSRegExp"); 2705 accumulator->Add("<JSRegExp");
2702 JSRegExp* regexp = JSRegExp::cast(this); 2706 JSRegExp* regexp = JSRegExp::cast(this);
2703 if (regexp->source()->IsString()) { 2707 if (regexp->source()->IsString()) {
2704 accumulator->Add(" "); 2708 accumulator->Add(" ");
2705 String::cast(regexp->source())->StringShortPrint(accumulator); 2709 String::cast(regexp->source())->StringShortPrint(accumulator);
2706 } 2710 }
2707 accumulator->Add(">"); 2711 accumulator->Add(">");
2708 2712
2709 break; 2713 break;
(...skipping 10072 matching lines...) Expand 10 before | Expand all | Expand 10 after
12782 case JS_ARGUMENTS_TYPE: 12786 case JS_ARGUMENTS_TYPE:
12783 case JS_PROMISE_TYPE: 12787 case JS_PROMISE_TYPE:
12784 case JS_REGEXP_TYPE: 12788 case JS_REGEXP_TYPE:
12785 case JS_SET_ITERATOR_TYPE: 12789 case JS_SET_ITERATOR_TYPE:
12786 case JS_SET_TYPE: 12790 case JS_SET_TYPE:
12787 case JS_SPECIAL_API_OBJECT_TYPE: 12791 case JS_SPECIAL_API_OBJECT_TYPE:
12788 case JS_TYPED_ARRAY_TYPE: 12792 case JS_TYPED_ARRAY_TYPE:
12789 case JS_VALUE_TYPE: 12793 case JS_VALUE_TYPE:
12790 case JS_WEAK_MAP_TYPE: 12794 case JS_WEAK_MAP_TYPE:
12791 case JS_WEAK_SET_TYPE: 12795 case JS_WEAK_SET_TYPE:
12796 case JS_WEAK_REF_TYPE:
12792 return true; 12797 return true;
12793 12798
12794 case BYTECODE_ARRAY_TYPE: 12799 case BYTECODE_ARRAY_TYPE:
12795 case BYTE_ARRAY_TYPE: 12800 case BYTE_ARRAY_TYPE:
12796 case CELL_TYPE: 12801 case CELL_TYPE:
12797 case CODE_TYPE: 12802 case CODE_TYPE:
12798 case FILLER_TYPE: 12803 case FILLER_TYPE:
12799 case FIXED_ARRAY_TYPE: 12804 case FIXED_ARRAY_TYPE:
12800 case FIXED_DOUBLE_ARRAY_TYPE: 12805 case FIXED_DOUBLE_ARRAY_TYPE:
12801 case FOREIGN_TYPE: 12806 case FOREIGN_TYPE:
(...skipping 6391 matching lines...) Expand 10 before | Expand all | Expand 10 after
19193 Object* value = table->Lookup(key); 19198 Object* value = table->Lookup(key);
19194 entries->set(count++, value); 19199 entries->set(count++, value);
19195 } 19200 }
19196 } 19201 }
19197 } 19202 }
19198 DCHECK_EQ(max_entries * values_per_entry, count); 19203 DCHECK_EQ(max_entries * values_per_entry, count);
19199 } 19204 }
19200 return isolate->factory()->NewJSArrayWithElements(entries); 19205 return isolate->factory()->NewJSArrayWithElements(entries);
19201 } 19206 }
19202 19207
19208 void JSWeakRef::Initialize(Handle<JSWeakRef> weak_ref,
19209 Isolate* isolate,
19210 Handle<JSObject> target,
19211 Handle<JSFunction> executor,
19212 Handle<Object> holdings) {
19213 isolate->factory()->InitJSWeakRef(weak_ref, target, executor, holdings);
19214 }
19215
19216 Handle<HeapObject> JSWeakRef::Value(Handle<JSWeakRef> weak_ref,
19217 Isolate* isolate) {
19218 if (weak_ref->target() == nullptr || weak_ref->target()->cleared()) {
19219 return isolate->factory()->null_value();
19220 }
19221 weak_ref->set_held(true);
19222 return Handle<HeapObject>(
19223 reinterpret_cast<HeapObject*>(weak_ref->target()->value()));
19224 }
19225
19226 void JSWeakRef::Clear(Handle<JSWeakRef> weak_ref,
19227 Isolate* isolate) {
19228 weak_ref->set_executor(nullptr);
19229 weak_ref->set_holdings(nullptr);
19230 weak_ref->set_target(nullptr);
19231 }
19232
19203 // Check if there is a break point at this source position. 19233 // Check if there is a break point at this source position.
19204 bool DebugInfo::HasBreakPoint(int source_position) { 19234 bool DebugInfo::HasBreakPoint(int source_position) {
19205 // Get the break point info object for this code offset. 19235 // Get the break point info object for this code offset.
19206 Object* break_point_info = GetBreakPointInfo(source_position); 19236 Object* break_point_info = GetBreakPointInfo(source_position);
19207 19237
19208 // If there is no break point info object or no break points in the break 19238 // If there is no break point info object or no break points in the break
19209 // point info object there is no break point at this code offset. 19239 // point info object there is no break point at this code offset.
19210 if (break_point_info->IsUndefined(GetIsolate())) return false; 19240 if (break_point_info->IsUndefined(GetIsolate())) return false;
19211 return BreakPointInfo::cast(break_point_info)->GetBreakPointCount() > 0; 19241 return BreakPointInfo::cast(break_point_info)->GetBreakPointCount() > 0;
19212 } 19242 }
(...skipping 1459 matching lines...) Expand 10 before | Expand all | Expand 10 after
20672 // depend on this. 20702 // depend on this.
20673 return DICTIONARY_ELEMENTS; 20703 return DICTIONARY_ELEMENTS;
20674 } 20704 }
20675 DCHECK_LE(kind, LAST_ELEMENTS_KIND); 20705 DCHECK_LE(kind, LAST_ELEMENTS_KIND);
20676 return kind; 20706 return kind;
20677 } 20707 }
20678 } 20708 }
20679 20709
20680 } // namespace internal 20710 } // namespace internal
20681 } // namespace v8 20711 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-body-descriptors-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698