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

Side by Side Diff: src/bootstrapper.cc

Issue 1775973002: Add GetProperty/GetElement to JSReceiver and use it where possible (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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/api.cc ('k') | src/builtins.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 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/bootstrapper.h" 5 #include "src/bootstrapper.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/api-natives.h" 8 #include "src/api-natives.h"
9 #include "src/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/extensions/externalize-string-extension.h" 10 #include "src/extensions/externalize-string-extension.h"
(...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 if (js_global_object_template.is_null()) { 894 if (js_global_object_template.is_null()) {
895 Handle<String> name = Handle<String>(heap()->empty_string()); 895 Handle<String> name = Handle<String>(heap()->empty_string());
896 Handle<Code> code = isolate()->builtins()->Illegal(); 896 Handle<Code> code = isolate()->builtins()->Illegal();
897 Handle<JSObject> prototype = 897 Handle<JSObject> prototype =
898 factory()->NewFunctionPrototype(isolate()->object_function()); 898 factory()->NewFunctionPrototype(isolate()->object_function());
899 js_global_object_function = factory()->NewFunction( 899 js_global_object_function = factory()->NewFunction(
900 name, code, prototype, JS_GLOBAL_OBJECT_TYPE, JSGlobalObject::kSize); 900 name, code, prototype, JS_GLOBAL_OBJECT_TYPE, JSGlobalObject::kSize);
901 #ifdef DEBUG 901 #ifdef DEBUG
902 LookupIterator it(prototype, factory()->constructor_string(), 902 LookupIterator it(prototype, factory()->constructor_string(),
903 LookupIterator::OWN_SKIP_INTERCEPTOR); 903 LookupIterator::OWN_SKIP_INTERCEPTOR);
904 Handle<Object> value = JSReceiver::GetProperty(&it).ToHandleChecked(); 904 Handle<Object> value = Object::GetProperty(&it).ToHandleChecked();
905 DCHECK(it.IsFound()); 905 DCHECK(it.IsFound());
906 DCHECK_EQ(*isolate()->object_function(), *value); 906 DCHECK_EQ(*isolate()->object_function(), *value);
907 #endif 907 #endif
908 } else { 908 } else {
909 Handle<FunctionTemplateInfo> js_global_object_constructor( 909 Handle<FunctionTemplateInfo> js_global_object_constructor(
910 FunctionTemplateInfo::cast(js_global_object_template->constructor())); 910 FunctionTemplateInfo::cast(js_global_object_template->constructor()));
911 js_global_object_function = ApiNatives::CreateApiFunction( 911 js_global_object_function = ApiNatives::CreateApiFunction(
912 isolate(), js_global_object_constructor, factory()->the_hole_value(), 912 isolate(), js_global_object_constructor, factory()->the_hole_value(),
913 ApiNatives::GlobalObjectType); 913 ApiNatives::GlobalObjectType);
914 } 914 }
(...skipping 1061 matching lines...) Expand 10 before | Expand all | Expand 10 after
1976 global, factory->InternalizeUtf8String(holder_expr)) 1976 global, factory->InternalizeUtf8String(holder_expr))
1977 .ToHandleChecked()); 1977 .ToHandleChecked());
1978 } 1978 }
1979 const char* inner = period_pos + 1; 1979 const char* inner = period_pos + 1;
1980 DCHECK(!strchr(inner, '.')); 1980 DCHECK(!strchr(inner, '.'));
1981 Vector<const char> property(holder_expr, 1981 Vector<const char> property(holder_expr,
1982 static_cast<int>(period_pos - holder_expr)); 1982 static_cast<int>(period_pos - holder_expr));
1983 Handle<String> property_string = factory->InternalizeUtf8String(property); 1983 Handle<String> property_string = factory->InternalizeUtf8String(property);
1984 DCHECK(!property_string.is_null()); 1984 DCHECK(!property_string.is_null());
1985 Handle<JSObject> object = Handle<JSObject>::cast( 1985 Handle<JSObject> object = Handle<JSObject>::cast(
1986 Object::GetProperty(global, property_string).ToHandleChecked()); 1986 JSReceiver::GetProperty(global, property_string).ToHandleChecked());
1987 if (strcmp("prototype", inner) == 0) { 1987 if (strcmp("prototype", inner) == 0) {
1988 Handle<JSFunction> function = Handle<JSFunction>::cast(object); 1988 Handle<JSFunction> function = Handle<JSFunction>::cast(object);
1989 return Handle<JSObject>(JSObject::cast(function->prototype())); 1989 return Handle<JSObject>(JSObject::cast(function->prototype()));
1990 } 1990 }
1991 Handle<String> inner_string = factory->InternalizeUtf8String(inner); 1991 Handle<String> inner_string = factory->InternalizeUtf8String(inner);
1992 DCHECK(!inner_string.is_null()); 1992 DCHECK(!inner_string.is_null());
1993 Handle<Object> value = 1993 Handle<Object> value =
1994 Object::GetProperty(object, inner_string).ToHandleChecked(); 1994 JSReceiver::GetProperty(object, inner_string).ToHandleChecked();
1995 return Handle<JSObject>::cast(value); 1995 return Handle<JSObject>::cast(value);
1996 } 1996 }
1997 1997
1998 void Genesis::ConfigureUtilsObject(GlobalContextType context_type) { 1998 void Genesis::ConfigureUtilsObject(GlobalContextType context_type) {
1999 switch (context_type) { 1999 switch (context_type) {
2000 // We still need the utils object to find debug functions. 2000 // We still need the utils object to find debug functions.
2001 case DEBUG_CONTEXT: 2001 case DEBUG_CONTEXT:
2002 return; 2002 return;
2003 // Expose the natives in global if a valid name for it is specified. 2003 // Expose the natives in global if a valid name for it is specified.
2004 case FULL_CONTEXT: { 2004 case FULL_CONTEXT: {
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after
2730 concat->shared()->DontAdaptArguments(); 2730 concat->shared()->DontAdaptArguments();
2731 DCHECK(concat->is_compiled()); 2731 DCHECK(concat->is_compiled());
2732 // Set the lengths for the functions to satisfy ECMA-262. 2732 // Set the lengths for the functions to satisfy ECMA-262.
2733 concat->shared()->set_length(1); 2733 concat->shared()->set_length(1);
2734 } 2734 }
2735 2735
2736 // Set up the Promise constructor. 2736 // Set up the Promise constructor.
2737 { 2737 {
2738 Handle<String> key = factory()->Promise_string(); 2738 Handle<String> key = factory()->Promise_string();
2739 Handle<JSFunction> function = Handle<JSFunction>::cast( 2739 Handle<JSFunction> function = Handle<JSFunction>::cast(
2740 Object::GetProperty(handle(native_context()->global_object()), key) 2740 JSReceiver::GetProperty(handle(native_context()->global_object()), key)
2741 .ToHandleChecked()); 2741 .ToHandleChecked());
2742 JSFunction::EnsureHasInitialMap(function); 2742 JSFunction::EnsureHasInitialMap(function);
2743 function->initial_map()->set_instance_type(JS_PROMISE_TYPE); 2743 function->initial_map()->set_instance_type(JS_PROMISE_TYPE);
2744 function->shared()->set_construct_stub( 2744 function->shared()->set_construct_stub(
2745 *isolate()->builtins()->JSBuiltinsConstructStub()); 2745 *isolate()->builtins()->JSBuiltinsConstructStub());
2746 InstallWithIntrinsicDefaultProto(isolate(), function, 2746 InstallWithIntrinsicDefaultProto(isolate(), function,
2747 Context::PROMISE_FUNCTION_INDEX); 2747 Context::PROMISE_FUNCTION_INDEX);
2748 } 2748 }
2749 2749
2750 InstallBuiltinFunctionIds(); 2750 InstallBuiltinFunctionIds();
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
3029 } 3029 }
3030 return CallUtilsFunction(isolate(), "PostDebug"); 3030 return CallUtilsFunction(isolate(), "PostDebug");
3031 } 3031 }
3032 3032
3033 3033
3034 static void InstallBuiltinFunctionId(Handle<JSObject> holder, 3034 static void InstallBuiltinFunctionId(Handle<JSObject> holder,
3035 const char* function_name, 3035 const char* function_name,
3036 BuiltinFunctionId id) { 3036 BuiltinFunctionId id) {
3037 Isolate* isolate = holder->GetIsolate(); 3037 Isolate* isolate = holder->GetIsolate();
3038 Handle<Object> function_object = 3038 Handle<Object> function_object =
3039 Object::GetProperty(isolate, holder, function_name).ToHandleChecked(); 3039 JSReceiver::GetProperty(isolate, holder, function_name).ToHandleChecked();
3040 Handle<JSFunction> function = Handle<JSFunction>::cast(function_object); 3040 Handle<JSFunction> function = Handle<JSFunction>::cast(function_object);
3041 function->shared()->set_builtin_function_id(id); 3041 function->shared()->set_builtin_function_id(id);
3042 } 3042 }
3043 3043
3044 3044
3045 #define INSTALL_BUILTIN_ID(holder_expr, fun_name, name) \ 3045 #define INSTALL_BUILTIN_ID(holder_expr, fun_name, name) \
3046 { #holder_expr, #fun_name, k##name } \ 3046 { #holder_expr, #fun_name, k##name } \
3047 , 3047 ,
3048 3048
3049 3049
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
3633 } 3633 }
3634 3634
3635 3635
3636 // Called when the top-level V8 mutex is destroyed. 3636 // Called when the top-level V8 mutex is destroyed.
3637 void Bootstrapper::FreeThreadResources() { 3637 void Bootstrapper::FreeThreadResources() {
3638 DCHECK(!IsActive()); 3638 DCHECK(!IsActive());
3639 } 3639 }
3640 3640
3641 } // namespace internal 3641 } // namespace internal
3642 } // namespace v8 3642 } // namespace v8
OLDNEW
« no previous file with comments | « src/api.cc ('k') | src/builtins.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698