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

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

Issue 867153003: new classes: special construct stub for derived classs and TDZ for `this`. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: CHECK_OK fixed Created 5 years, 10 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/preparser.cc ('k') | src/scopes.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 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 <stdlib.h> 5 #include <stdlib.h>
6 #include <limits> 6 #include <limits>
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/isolate-inl.h" 10 #include "src/isolate-inl.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 isolate->factory()->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); 100 isolate->factory()->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
101 map->SetPrototype(prototype_parent); 101 map->SetPrototype(prototype_parent);
102 map->set_constructor(*constructor); 102 map->set_constructor(*constructor);
103 Handle<JSObject> prototype = isolate->factory()->NewJSObjectFromMap(map); 103 Handle<JSObject> prototype = isolate->factory()->NewJSObjectFromMap(map);
104 104
105 Handle<String> name_string = name->IsString() 105 Handle<String> name_string = name->IsString()
106 ? Handle<String>::cast(name) 106 ? Handle<String>::cast(name)
107 : isolate->factory()->empty_string(); 107 : isolate->factory()->empty_string();
108 constructor->shared()->set_name(*name_string); 108 constructor->shared()->set_name(*name_string);
109 109
110 if (FLAG_experimental_classes) {
111 if (!super_class->IsTheHole() && !super_class->IsNull()) {
112 Handle<Code> stub(isolate->builtins()->JSConstructStubForDerived());
113 constructor->shared()->set_construct_stub(*stub);
114 }
115 }
116
110 JSFunction::SetPrototype(constructor, prototype); 117 JSFunction::SetPrototype(constructor, prototype);
111 PropertyAttributes attribs = 118 PropertyAttributes attribs =
112 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); 119 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
113 RETURN_FAILURE_ON_EXCEPTION( 120 RETURN_FAILURE_ON_EXCEPTION(
114 isolate, JSObject::SetOwnPropertyIgnoreAttributes( 121 isolate, JSObject::SetOwnPropertyIgnoreAttributes(
115 constructor, isolate->factory()->prototype_string(), 122 constructor, isolate->factory()->prototype_string(),
116 prototype, attribs)); 123 prototype, attribs));
117 124
118 // TODO(arv): Only do this conditionally. 125 // TODO(arv): Only do this conditionally.
119 Handle<Symbol> home_object_symbol(isolate->heap()->home_object_symbol()); 126 Handle<Symbol> home_object_symbol(isolate->heap()->home_object_symbol());
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 } 442 }
436 443
437 Handle<Object> result; 444 Handle<Object> result;
438 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 445 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
439 isolate, result, 446 isolate, result,
440 Execution::Call(isolate, proto_function, receiver, argc, argv, false)); 447 Execution::Call(isolate, proto_function, receiver, argc, argv, false));
441 return *result; 448 return *result;
442 } 449 }
443 } 450 }
444 } // namespace v8::internal 451 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/preparser.cc ('k') | src/scopes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698