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

Side by Side Diff: src/accessors.cc

Issue 348313002: Introduce a PrototypeIterator template and use it all over the place (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebase Created 6 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 | Annotate | Revision Log
« no previous file with comments | « BUILD.gn ('k') | src/api.cc » ('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 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/accessors.h" 7 #include "src/accessors.h"
8 #include "src/api.h" 8 #include "src/api.h"
9 #include "src/compiler.h" 9 #include "src/compiler.h"
10 #include "src/contexts.h" 10 #include "src/contexts.h"
11 #include "src/deoptimizer.h" 11 #include "src/deoptimizer.h"
12 #include "src/execution.h" 12 #include "src/execution.h"
13 #include "src/factory.h" 13 #include "src/factory.h"
14 #include "src/frames-inl.h" 14 #include "src/frames-inl.h"
15 #include "src/isolate.h" 15 #include "src/isolate.h"
16 #include "src/list-inl.h" 16 #include "src/list-inl.h"
17 #include "src/property-details.h" 17 #include "src/property-details.h"
18 #include "src/prototype-iterator.h"
18 19
19 namespace v8 { 20 namespace v8 {
20 namespace internal { 21 namespace internal {
21 22
22 23
23 // We have a slight impedance mismatch between the external API and the way we 24 // We have a slight impedance mismatch between the external API and the way we
24 // use callbacks internally: Externally, callbacks can only be used with 25 // use callbacks internally: Externally, callbacks can only be used with
25 // v8::Object, but internally we even have callbacks on entities which are 26 // v8::Object, but internally we even have callbacks on entities which are
26 // higher in the hierarchy, so we can only return i::Object here, not 27 // higher in the hierarchy, so we can only return i::Object here, not
27 // i::JSObject. 28 // i::JSObject.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 info->set_expected_receiver_type(accessor->expected_receiver_type()); 61 info->set_expected_receiver_type(accessor->expected_receiver_type());
61 info->set_getter(accessor->getter()); 62 info->set_getter(accessor->getter());
62 info->set_setter(accessor->setter()); 63 info->set_setter(accessor->setter());
63 info->set_data(accessor->data()); 64 info->set_data(accessor->data());
64 return info; 65 return info;
65 } 66 }
66 67
67 68
68 template <class C> 69 template <class C>
69 static C* FindInstanceOf(Isolate* isolate, Object* obj) { 70 static C* FindInstanceOf(Isolate* isolate, Object* obj) {
70 for (Object* cur = obj; !cur->IsNull(); cur = cur->GetPrototype(isolate)) { 71 for (PrototypeIterator<STORE_AS_POINTER, TYPE_BASED_WALK, END_AT_NULL_VALUE>
71 if (Is<C>(cur)) return C::cast(cur); 72 iter(isolate, obj); !iter.IsAtEnd(); iter.Advance()) {
73 if (Is<C>(iter.GetCurrent())) return C::cast(iter.GetCurrent());
72 } 74 }
73 return NULL; 75 return NULL;
74 } 76 }
75 77
76 78
77 static V8_INLINE bool CheckForName(Handle<String> name, 79 static V8_INLINE bool CheckForName(Handle<String> name,
78 Handle<String> property_name, 80 Handle<String> property_name,
79 int offset, 81 int offset,
80 int* object_offset) { 82 int* object_offset) {
81 if (String::Equals(name, property_name)) { 83 if (String::Equals(name, property_name)) {
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 // 769 //
768 770
769 static Handle<Object> GetFunctionPrototype(Isolate* isolate, 771 static Handle<Object> GetFunctionPrototype(Isolate* isolate,
770 Handle<Object> receiver) { 772 Handle<Object> receiver) {
771 Handle<JSFunction> function; 773 Handle<JSFunction> function;
772 { 774 {
773 DisallowHeapAllocation no_allocation; 775 DisallowHeapAllocation no_allocation;
774 JSFunction* function_raw = FindInstanceOf<JSFunction>(isolate, *receiver); 776 JSFunction* function_raw = FindInstanceOf<JSFunction>(isolate, *receiver);
775 if (function_raw == NULL) return isolate->factory()->undefined_value(); 777 if (function_raw == NULL) return isolate->factory()->undefined_value();
776 while (!function_raw->should_have_prototype()) { 778 while (!function_raw->should_have_prototype()) {
777 function_raw = FindInstanceOf<JSFunction>(isolate, 779 function_raw = FindInstanceOf<JSFunction>(
778 function_raw->GetPrototype()); 780 isolate, SAFE_GET_PROTOTYPE_FAST(function_raw));
779 // There has to be one because we hit the getter. 781 // There has to be one because we hit the getter.
780 ASSERT(function_raw != NULL); 782 ASSERT(function_raw != NULL);
781 } 783 }
782 function = Handle<JSFunction>(function_raw, isolate); 784 function = Handle<JSFunction>(function_raw, isolate);
783 } 785 }
784 786
785 if (!function->has_prototype()) { 787 if (!function->has_prototype()) {
786 Handle<Object> proto = isolate->factory()->NewFunctionPrototype(function); 788 Handle<Object> proto = isolate->factory()->NewFunctionPrototype(function);
787 JSFunction::SetPrototype(function, proto); 789 JSFunction::SetPrototype(function, proto);
788 } 790 }
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
1352 info->set_data(Smi::FromInt(index)); 1354 info->set_data(Smi::FromInt(index));
1353 Handle<Object> getter = v8::FromCData(isolate, &ModuleGetExport); 1355 Handle<Object> getter = v8::FromCData(isolate, &ModuleGetExport);
1354 Handle<Object> setter = v8::FromCData(isolate, &ModuleSetExport); 1356 Handle<Object> setter = v8::FromCData(isolate, &ModuleSetExport);
1355 info->set_getter(*getter); 1357 info->set_getter(*getter);
1356 if (!(attributes & ReadOnly)) info->set_setter(*setter); 1358 if (!(attributes & ReadOnly)) info->set_setter(*setter);
1357 return info; 1359 return info;
1358 } 1360 }
1359 1361
1360 1362
1361 } } // namespace v8::internal 1363 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « BUILD.gn ('k') | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698