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

Side by Side Diff: src/bootstrapper.cc

Issue 233233004: Handlify GetProperty. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 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 | « src/api.cc ('k') | src/debug.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 "bootstrapper.h" 5 #include "bootstrapper.h"
6 6
7 #include "accessors.h" 7 #include "accessors.h"
8 #include "isolate-inl.h" 8 #include "isolate-inl.h"
9 #include "natives.h" 9 #include "natives.h"
10 #include "snapshot.h" 10 #include "snapshot.h"
(...skipping 1497 matching lines...) Expand 10 before | Expand all | Expand 10 after
1508 ? top_context->builtins() 1508 ? top_context->builtins()
1509 : top_context->global_object(), 1509 : top_context->global_object(),
1510 isolate); 1510 isolate);
1511 return !Execution::Call( 1511 return !Execution::Call(
1512 isolate, fun, receiver, 0, NULL).is_null(); 1512 isolate, fun, receiver, 0, NULL).is_null();
1513 } 1513 }
1514 1514
1515 1515
1516 #define INSTALL_NATIVE(Type, name, var) \ 1516 #define INSTALL_NATIVE(Type, name, var) \
1517 Handle<String> var##_name = \ 1517 Handle<String> var##_name = \
1518 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR(name)); \ 1518 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR(name)); \
1519 Handle<Object> var##_native = GlobalObject::GetPropertyNoExceptionThrown( \ 1519 Handle<Object> var##_native = Object::GetProperty( \
1520 handle(native_context()->builtins()), var##_name); \ 1520 handle(native_context()->builtins()), var##_name).ToHandleChecked(); \
1521 native_context()->set_##var(Type::cast(*var##_native)); 1521 native_context()->set_##var(Type::cast(*var##_native));
1522 1522
1523 1523
1524 void Genesis::InstallNativeFunctions() { 1524 void Genesis::InstallNativeFunctions() {
1525 HandleScope scope(isolate()); 1525 HandleScope scope(isolate());
1526 INSTALL_NATIVE(JSFunction, "CreateDate", create_date_fun); 1526 INSTALL_NATIVE(JSFunction, "CreateDate", create_date_fun);
1527 INSTALL_NATIVE(JSFunction, "ToNumber", to_number_fun); 1527 INSTALL_NATIVE(JSFunction, "ToNumber", to_number_fun);
1528 INSTALL_NATIVE(JSFunction, "ToString", to_string_fun); 1528 INSTALL_NATIVE(JSFunction, "ToString", to_string_fun);
1529 INSTALL_NATIVE(JSFunction, "ToDetailString", to_detail_string_fun); 1529 INSTALL_NATIVE(JSFunction, "ToDetailString", to_detail_string_fun);
1530 INSTALL_NATIVE(JSFunction, "ToObject", to_object_fun); 1530 INSTALL_NATIVE(JSFunction, "ToObject", to_object_fun);
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
1886 Handle<JSFunction> string_function(native_context()->string_function()); 1886 Handle<JSFunction> string_function(native_context()->string_function());
1887 ASSERT(JSObject::cast( 1887 ASSERT(JSObject::cast(
1888 string_function->initial_map()->prototype())->HasFastProperties()); 1888 string_function->initial_map()->prototype())->HasFastProperties());
1889 native_context()->set_string_function_prototype_map( 1889 native_context()->set_string_function_prototype_map(
1890 HeapObject::cast(string_function->initial_map()->prototype())->map()); 1890 HeapObject::cast(string_function->initial_map()->prototype())->map());
1891 1891
1892 // Install Function.prototype.call and apply. 1892 // Install Function.prototype.call and apply.
1893 { Handle<String> key = factory()->function_class_string(); 1893 { Handle<String> key = factory()->function_class_string();
1894 Handle<JSFunction> function = 1894 Handle<JSFunction> function =
1895 Handle<JSFunction>::cast(Object::GetProperty( 1895 Handle<JSFunction>::cast(Object::GetProperty(
1896 isolate()->global_object(), key)); 1896 isolate()->global_object(), key).ToHandleChecked());
1897 Handle<JSObject> proto = 1897 Handle<JSObject> proto =
1898 Handle<JSObject>(JSObject::cast(function->instance_prototype())); 1898 Handle<JSObject>(JSObject::cast(function->instance_prototype()));
1899 1899
1900 // Install the call and the apply functions. 1900 // Install the call and the apply functions.
1901 Handle<JSFunction> call = 1901 Handle<JSFunction> call =
1902 InstallFunction(proto, "call", JS_OBJECT_TYPE, JSObject::kHeaderSize, 1902 InstallFunction(proto, "call", JS_OBJECT_TYPE, JSObject::kHeaderSize,
1903 Handle<JSObject>::null(), 1903 Handle<JSObject>::null(),
1904 Builtins::kFunctionCall, 1904 Builtins::kFunctionCall,
1905 false, false); 1905 false, false);
1906 Handle<JSFunction> apply = 1906 Handle<JSFunction> apply =
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
2035 if (period_pos == NULL) { 2035 if (period_pos == NULL) {
2036 return Handle<JSObject>::cast(Object::GetPropertyOrElement( 2036 return Handle<JSObject>::cast(Object::GetPropertyOrElement(
2037 global, factory->InternalizeUtf8String(holder_expr)).ToHandleChecked()); 2037 global, factory->InternalizeUtf8String(holder_expr)).ToHandleChecked());
2038 } 2038 }
2039 ASSERT_EQ(".prototype", period_pos); 2039 ASSERT_EQ(".prototype", period_pos);
2040 Vector<const char> property(holder_expr, 2040 Vector<const char> property(holder_expr,
2041 static_cast<int>(period_pos - holder_expr)); 2041 static_cast<int>(period_pos - holder_expr));
2042 Handle<String> property_string = factory->InternalizeUtf8String(property); 2042 Handle<String> property_string = factory->InternalizeUtf8String(property);
2043 ASSERT(!property_string.is_null()); 2043 ASSERT(!property_string.is_null());
2044 Handle<JSFunction> function = Handle<JSFunction>::cast( 2044 Handle<JSFunction> function = Handle<JSFunction>::cast(
2045 Object::GetProperty(global, property_string)); 2045 Object::GetProperty(global, property_string).ToHandleChecked());
2046 return Handle<JSObject>(JSObject::cast(function->prototype())); 2046 return Handle<JSObject>(JSObject::cast(function->prototype()));
2047 } 2047 }
2048 2048
2049 2049
2050 static void InstallBuiltinFunctionId(Handle<JSObject> holder, 2050 static void InstallBuiltinFunctionId(Handle<JSObject> holder,
2051 const char* function_name, 2051 const char* function_name,
2052 BuiltinFunctionId id) { 2052 BuiltinFunctionId id) {
2053 Factory* factory = holder->GetIsolate()->factory(); 2053 Factory* factory = holder->GetIsolate()->factory();
2054 Handle<String> name = factory->InternalizeUtf8String(function_name); 2054 Handle<String> name = factory->InternalizeUtf8String(function_name);
2055 Handle<Object> function_object = Object::GetProperty(holder, name); 2055 Handle<Object> function_object =
2056 ASSERT(!function_object.is_null()); 2056 Object::GetProperty(holder, name).ToHandleChecked();
2057 Handle<JSFunction> function = Handle<JSFunction>::cast(function_object); 2057 Handle<JSFunction> function = Handle<JSFunction>::cast(function_object);
2058 function->shared()->set_function_data(Smi::FromInt(id)); 2058 function->shared()->set_function_data(Smi::FromInt(id));
2059 } 2059 }
2060 2060
2061 2061
2062 void Genesis::InstallBuiltinFunctionIds() { 2062 void Genesis::InstallBuiltinFunctionIds() {
2063 HandleScope scope(isolate()); 2063 HandleScope scope(isolate());
2064 #define INSTALL_BUILTIN_ID(holder_expr, fun_name, name) \ 2064 #define INSTALL_BUILTIN_ID(holder_expr, fun_name, name) \
2065 { \ 2065 { \
2066 Handle<JSObject> holder = ResolveBuiltinIdHolder( \ 2066 Handle<JSObject> holder = ResolveBuiltinIdHolder( \
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
2342 } 2342 }
2343 2343
2344 2344
2345 bool Genesis::InstallJSBuiltins(Handle<JSBuiltinsObject> builtins) { 2345 bool Genesis::InstallJSBuiltins(Handle<JSBuiltinsObject> builtins) {
2346 HandleScope scope(isolate()); 2346 HandleScope scope(isolate());
2347 for (int i = 0; i < Builtins::NumberOfJavaScriptBuiltins(); i++) { 2347 for (int i = 0; i < Builtins::NumberOfJavaScriptBuiltins(); i++) {
2348 Builtins::JavaScript id = static_cast<Builtins::JavaScript>(i); 2348 Builtins::JavaScript id = static_cast<Builtins::JavaScript>(i);
2349 Handle<String> name = 2349 Handle<String> name =
2350 factory()->InternalizeUtf8String(Builtins::GetName(id)); 2350 factory()->InternalizeUtf8String(Builtins::GetName(id));
2351 Handle<Object> function_object = 2351 Handle<Object> function_object =
2352 GlobalObject::GetPropertyNoExceptionThrown(builtins, name); 2352 Object::GetProperty(builtins, name).ToHandleChecked();
2353 Handle<JSFunction> function = Handle<JSFunction>::cast(function_object); 2353 Handle<JSFunction> function = Handle<JSFunction>::cast(function_object);
2354 builtins->set_javascript_builtin(id, *function); 2354 builtins->set_javascript_builtin(id, *function);
2355 if (!Compiler::EnsureCompiled(function, CLEAR_EXCEPTION)) { 2355 if (!Compiler::EnsureCompiled(function, CLEAR_EXCEPTION)) {
2356 return false; 2356 return false;
2357 } 2357 }
2358 builtins->set_javascript_builtin_code(id, function->shared()->code()); 2358 builtins->set_javascript_builtin_code(id, function->shared()->code());
2359 } 2359 }
2360 return true; 2360 return true;
2361 } 2361 }
2362 2362
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
2716 return from + sizeof(NestingCounterType); 2716 return from + sizeof(NestingCounterType);
2717 } 2717 }
2718 2718
2719 2719
2720 // Called when the top-level V8 mutex is destroyed. 2720 // Called when the top-level V8 mutex is destroyed.
2721 void Bootstrapper::FreeThreadResources() { 2721 void Bootstrapper::FreeThreadResources() {
2722 ASSERT(!IsActive()); 2722 ASSERT(!IsActive());
2723 } 2723 }
2724 2724
2725 } } // namespace v8::internal 2725 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/api.cc ('k') | src/debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698