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

Side by Side Diff: src/runtime/runtime-classes.cc

Issue 1316933002: [es6] Initial steps towards a correct implementation of IsCallable. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: ia32, arm and arm64 ports. Misc cleanups. Created 5 years, 3 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
OLDNEW
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/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 #include <limits> 8 #include <limits>
9 9
10 #include "src/arguments.h" 10 #include "src/arguments.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 return *name; 72 return *name;
73 } 73 }
74 74
75 75
76 RUNTIME_FUNCTION(Runtime_ToMethod) { 76 RUNTIME_FUNCTION(Runtime_ToMethod) {
77 HandleScope scope(isolate); 77 HandleScope scope(isolate);
78 DCHECK(args.length() == 2); 78 DCHECK(args.length() == 2);
79 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); 79 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0);
80 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); 80 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1);
81 Handle<JSFunction> clone = JSFunction::CloneClosure(fun); 81 Handle<JSFunction> clone = JSFunction::CloneClosure(fun);
82 Handle<Symbol> home_object_symbol(isolate->heap()->home_object_symbol()); 82 Handle<Symbol> home_object_symbol(isolate->factory()->home_object_symbol());
Michael Starzinger 2015/08/27 10:47:14 nit: Use assignment instead of constructor for thi
83 JSObject::SetOwnPropertyIgnoreAttributes(clone, home_object_symbol, 83 JSObject::SetOwnPropertyIgnoreAttributes(clone, home_object_symbol,
84 home_object, DONT_ENUM).Assert(); 84 home_object, DONT_ENUM).Assert();
85 return *clone; 85 return *clone;
86 } 86 }
87 87
88 88
89 RUNTIME_FUNCTION(Runtime_HomeObjectSymbol) { 89 RUNTIME_FUNCTION(Runtime_HomeObjectSymbol) {
90 DCHECK(args.length() == 0); 90 DCHECK(args.length() == 0);
91 return isolate->heap()->home_object_symbol(); 91 return isolate->heap()->home_object_symbol();
92 } 92 }
93 93
94 94
95 static MaybeHandle<Object> DefineClass(Isolate* isolate, Handle<Object> name, 95 static MaybeHandle<Object> DefineClass(Isolate* isolate, Handle<Object> name,
96 Handle<Object> super_class, 96 Handle<Object> super_class,
97 Handle<JSFunction> constructor, 97 Handle<JSFunction> constructor,
98 int start_position, int end_position) { 98 int start_position, int end_position) {
99 Handle<Object> prototype_parent; 99 Handle<Object> prototype_parent;
100 Handle<Object> constructor_parent; 100 Handle<Object> constructor_parent;
101 101
102 if (super_class->IsTheHole()) { 102 if (super_class->IsTheHole()) {
103 prototype_parent = isolate->initial_object_prototype(); 103 prototype_parent = isolate->initial_object_prototype();
104 } else { 104 } else {
105 if (super_class->IsNull()) { 105 if (super_class->IsNull()) {
106 prototype_parent = isolate->factory()->null_value(); 106 prototype_parent = isolate->factory()->null_value();
107 } else if (super_class->IsSpecFunction()) { 107 } else if (super_class->IsJSFunction()) { // TODO(bmeurer): IsConstructor.
108 if (Handle<JSFunction>::cast(super_class)->shared()->is_generator()) { 108 if (Handle<JSFunction>::cast(super_class)->shared()->is_generator()) {
109 THROW_NEW_ERROR( 109 THROW_NEW_ERROR(
110 isolate, 110 isolate,
111 NewTypeError(MessageTemplate::kExtendsValueGenerator, super_class), 111 NewTypeError(MessageTemplate::kExtendsValueGenerator, super_class),
112 Object); 112 Object);
113 } 113 }
114 ASSIGN_RETURN_ON_EXCEPTION( 114 ASSIGN_RETURN_ON_EXCEPTION(
115 isolate, prototype_parent, 115 isolate, prototype_parent,
116 Runtime::GetObjectProperty(isolate, super_class, 116 Runtime::GetObjectProperty(isolate, super_class,
117 isolate->factory()->prototype_string(), 117 isolate->factory()->prototype_string(),
118 SLOPPY), 118 SLOPPY),
119 Object); 119 Object);
120 if (!prototype_parent->IsNull() && !prototype_parent->IsSpecObject()) { 120 if (!prototype_parent->IsNull() && !prototype_parent->IsSpecObject()) {
121 THROW_NEW_ERROR( 121 THROW_NEW_ERROR(
122 isolate, NewTypeError(MessageTemplate::kPrototypeParentNotAnObject, 122 isolate, NewTypeError(MessageTemplate::kPrototypeParentNotAnObject,
123 prototype_parent), 123 prototype_parent),
124 Object); 124 Object);
125 } 125 }
126 constructor_parent = super_class; 126 constructor_parent = super_class;
127 } else { 127 } else {
128 // TODO(arv): Should be IsConstructor.
129 THROW_NEW_ERROR( 128 THROW_NEW_ERROR(
130 isolate, 129 isolate,
131 NewTypeError(MessageTemplate::kExtendsValueNotFunction, super_class), 130 NewTypeError(MessageTemplate::kExtendsValueNotFunction, super_class),
132 Object); 131 Object);
133 } 132 }
134 } 133 }
135 134
136 Handle<Map> map = 135 Handle<Map> map =
137 isolate->factory()->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); 136 isolate->factory()->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
138 if (constructor->map()->is_strong()) { 137 if (constructor->map()->is_strong()) {
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 Handle<Object> result; 556 Handle<Object> result;
558 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 557 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
559 isolate, result, 558 isolate, result,
560 Execution::Call(isolate, reflect, isolate->factory()->undefined_value(), 559 Execution::Call(isolate, reflect, isolate->factory()->undefined_value(),
561 arraysize(argv), argv)); 560 arraysize(argv), argv));
562 561
563 return *result; 562 return *result;
564 } 563 }
565 } // namespace internal 564 } // namespace internal
566 } // namespace v8 565 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698