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

Side by Side Diff: src/bootstrapper.cc

Issue 93066: Built-in JSON support (Closed)
Patch Set: Created 11 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
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 { // -- R e g E x p 734 { // -- R e g E x p
735 // Builtin functions for RegExp.prototype. 735 // Builtin functions for RegExp.prototype.
736 Handle<JSFunction> regexp_fun = 736 Handle<JSFunction> regexp_fun =
737 InstallFunction(global, "RegExp", JS_REGEXP_TYPE, JSRegExp::kSize, 737 InstallFunction(global, "RegExp", JS_REGEXP_TYPE, JSRegExp::kSize,
738 Top::initial_object_prototype(), Builtins::Illegal, 738 Top::initial_object_prototype(), Builtins::Illegal,
739 true); 739 true);
740 740
741 global_context()->set_regexp_function(*regexp_fun); 741 global_context()->set_regexp_function(*regexp_fun);
742 } 742 }
743 743
744 { // -- J S O N
745 Handle<String> name = Factory::NewStringFromAscii(CStrVector("JSON"));
746 Handle<JSFunction> cons = Factory::NewFunction(
747 name,
748 Factory::the_hole_value());
749 cons->SetInstancePrototype(global_context()->initial_object_prototype());
750 cons->SetInstanceClassName(*name);
751 Handle<JSObject> json_object = Factory::NewJSObject(cons, TENURED);
752 ASSERT(json_object->IsJSObject());
753 SetProperty(global, name, json_object, DONT_ENUM);
754 global_context()->set_json_object(*json_object);
755 }
756
744 { // --- arguments_boilerplate_ 757 { // --- arguments_boilerplate_
745 // Make sure we can recognize argument objects at runtime. 758 // Make sure we can recognize argument objects at runtime.
746 // This is done by introducing an anonymous function with 759 // This is done by introducing an anonymous function with
747 // class_name equals 'Arguments'. 760 // class_name equals 'Arguments'.
748 Handle<String> symbol = Factory::LookupAsciiSymbol("Arguments"); 761 Handle<String> symbol = Factory::LookupAsciiSymbol("Arguments");
749 Handle<Code> code = Handle<Code>(Builtins::builtin(Builtins::Illegal)); 762 Handle<Code> code = Handle<Code>(Builtins::builtin(Builtins::Illegal));
750 Handle<JSObject> prototype = 763 Handle<JSObject> prototype =
751 Handle<JSObject>( 764 Handle<JSObject>(
752 JSObject::cast(global_context()->object_function()->prototype())); 765 JSObject::cast(global_context()->object_function()->prototype()));
753 766
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 1074
1062 // Setup natives with lazy loading. 1075 // Setup natives with lazy loading.
1063 SetupLazy(Handle<JSFunction>(global_context()->date_function()), 1076 SetupLazy(Handle<JSFunction>(global_context()->date_function()),
1064 Natives::GetIndex("date"), 1077 Natives::GetIndex("date"),
1065 Top::global_context(), 1078 Top::global_context(),
1066 Handle<Context>(Top::context()->runtime_context())); 1079 Handle<Context>(Top::context()->runtime_context()));
1067 SetupLazy(Handle<JSFunction>(global_context()->regexp_function()), 1080 SetupLazy(Handle<JSFunction>(global_context()->regexp_function()),
1068 Natives::GetIndex("regexp"), 1081 Natives::GetIndex("regexp"),
1069 Top::global_context(), 1082 Top::global_context(),
1070 Handle<Context>(Top::context()->runtime_context())); 1083 Handle<Context>(Top::context()->runtime_context()));
1084 SetupLazy(Handle<JSObject>(global_context()->json_object()),
1085 Natives::GetIndex("json"),
1086 Top::global_context(),
1087 Handle<Context>(Top::context()->runtime_context()));
1071 1088
1072 } else if (strlen(FLAG_natives_file) != 0) { 1089 } else if (strlen(FLAG_natives_file) != 0) {
1073 // Otherwise install natives from natives file if file exists and 1090 // Otherwise install natives from natives file if file exists and
1074 // compiles. 1091 // compiles.
1075 bool exists; 1092 bool exists;
1076 Vector<const char> source = ReadFile(FLAG_natives_file, &exists); 1093 Vector<const char> source = ReadFile(FLAG_natives_file, &exists);
1077 Handle<String> source_string = Factory::NewStringFromAscii(source); 1094 Handle<String> source_string = Factory::NewStringFromAscii(source);
1078 if (source.is_empty()) return false; 1095 if (source.is_empty()) return false;
1079 bool result = CompileNative(CStrVector(FLAG_natives_file), source_string); 1096 bool result = CompileNative(CStrVector(FLAG_natives_file), source_string);
1080 if (!result) return false; 1097 if (!result) return false;
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
1532 } 1549 }
1533 1550
1534 1551
1535 // Restore statics that are thread local. 1552 // Restore statics that are thread local.
1536 char* Genesis::RestoreState(char* from) { 1553 char* Genesis::RestoreState(char* from) {
1537 current_ = *reinterpret_cast<Genesis**>(from); 1554 current_ = *reinterpret_cast<Genesis**>(from);
1538 return from + sizeof(current_); 1555 return from + sizeof(current_);
1539 } 1556 }
1540 1557
1541 } } // namespace v8::internal 1558 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698