OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/api.h" | 5 #include "src/api.h" |
6 | 6 |
7 #include <string.h> // For memcpy, strlen. | 7 #include <string.h> // For memcpy, strlen. |
8 #ifdef V8_USE_ADDRESS_SANITIZER | 8 #ifdef V8_USE_ADDRESS_SANITIZER |
9 #include <sanitizer/asan_interface.h> | 9 #include <sanitizer/asan_interface.h> |
10 #endif // V8_USE_ADDRESS_SANITIZER | 10 #endif // V8_USE_ADDRESS_SANITIZER |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 #include "src/json-parser.h" | 42 #include "src/json-parser.h" |
43 #include "src/messages.h" | 43 #include "src/messages.h" |
44 #include "src/parsing/parser.h" | 44 #include "src/parsing/parser.h" |
45 #include "src/parsing/scanner-character-streams.h" | 45 #include "src/parsing/scanner-character-streams.h" |
46 #include "src/pending-compilation-error-handler.h" | 46 #include "src/pending-compilation-error-handler.h" |
47 #include "src/profiler/cpu-profiler.h" | 47 #include "src/profiler/cpu-profiler.h" |
48 #include "src/profiler/heap-profiler.h" | 48 #include "src/profiler/heap-profiler.h" |
49 #include "src/profiler/heap-snapshot-generator-inl.h" | 49 #include "src/profiler/heap-snapshot-generator-inl.h" |
50 #include "src/profiler/profile-generator-inl.h" | 50 #include "src/profiler/profile-generator-inl.h" |
51 #include "src/profiler/sampler.h" | 51 #include "src/profiler/sampler.h" |
52 #include "src/property.h" | |
53 #include "src/property-descriptor.h" | 52 #include "src/property-descriptor.h" |
54 #include "src/property-details.h" | 53 #include "src/property-details.h" |
| 54 #include "src/property.h" |
55 #include "src/prototype.h" | 55 #include "src/prototype.h" |
| 56 #include "src/runtime-profiler.h" |
56 #include "src/runtime/runtime.h" | 57 #include "src/runtime/runtime.h" |
57 #include "src/runtime-profiler.h" | |
58 #include "src/simulator.h" | 58 #include "src/simulator.h" |
59 #include "src/snapshot/natives.h" | 59 #include "src/snapshot/natives.h" |
60 #include "src/snapshot/snapshot.h" | 60 #include "src/snapshot/snapshot.h" |
61 #include "src/startup-data-util.h" | 61 #include "src/startup-data-util.h" |
62 #include "src/tracing/trace-event.h" | 62 #include "src/tracing/trace-event.h" |
63 #include "src/unicode-inl.h" | 63 #include "src/unicode-inl.h" |
64 #include "src/v8.h" | 64 #include "src/v8.h" |
65 #include "src/v8threads.h" | 65 #include "src/v8threads.h" |
66 #include "src/version.h" | 66 #include "src/version.h" |
67 #include "src/vm-state-inl.h" | 67 #include "src/vm-state-inl.h" |
68 | 68 |
69 | |
70 namespace v8 { | 69 namespace v8 { |
71 | 70 |
72 #define LOG_API(isolate, expr) LOG(isolate, ApiEntryCall(expr)) | 71 #define LOG_API(isolate, expr) LOG(isolate, ApiEntryCall(expr)) |
73 | 72 |
74 | 73 |
75 #define ENTER_V8(isolate) i::VMState<v8::OTHER> __state__((isolate)) | 74 #define ENTER_V8(isolate) i::VMState<v8::OTHER> __state__((isolate)) |
76 | 75 |
77 | 76 |
78 #define PREPARE_FOR_EXECUTION_GENERIC(isolate, context, function_name, \ | 77 #define PREPARE_FOR_EXECUTION_GENERIC(isolate, context, function_name, \ |
79 bailout_value, HandleScopeClass, \ | 78 bailout_value, HandleScopeClass, \ |
(...skipping 2665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2745 RETURN_ESCAPED(result); | 2744 RETURN_ESCAPED(result); |
2746 } | 2745 } |
2747 | 2746 |
2748 | 2747 |
2749 Local<Value> JSON::Parse(Local<String> json_string) { | 2748 Local<Value> JSON::Parse(Local<String> json_string) { |
2750 auto isolate = reinterpret_cast<v8::Isolate*>( | 2749 auto isolate = reinterpret_cast<v8::Isolate*>( |
2751 Utils::OpenHandle(*json_string)->GetIsolate()); | 2750 Utils::OpenHandle(*json_string)->GetIsolate()); |
2752 RETURN_TO_LOCAL_UNCHECKED(Parse(isolate, json_string), Value); | 2751 RETURN_TO_LOCAL_UNCHECKED(Parse(isolate, json_string), Value); |
2753 } | 2752 } |
2754 | 2753 |
| 2754 MaybeLocal<String> JSON::Stringify(Isolate* v8_isolate, |
| 2755 Local<Object> json_object) { |
| 2756 auto isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
| 2757 PREPARE_FOR_EXECUTION_WITH_ISOLATE(isolate, "JSON::Stringify", String); |
| 2758 i::Handle<i::Object> object = Utils::OpenHandle(*json_object); |
| 2759 i::Handle<i::Object> maybe; |
| 2760 has_pending_exception = |
| 2761 !i::Runtime::BasicJsonStringify(isolate, object).ToHandle(&maybe); |
| 2762 RETURN_ON_FAILED_EXECUTION(String); |
| 2763 Local<String> result; |
| 2764 has_pending_exception = |
| 2765 !ToLocal<String>(i::Object::ToString(isolate, maybe), &result); |
| 2766 RETURN_ON_FAILED_EXECUTION(String); |
| 2767 RETURN_ESCAPED(result); |
| 2768 } |
2755 | 2769 |
2756 // --- D a t a --- | 2770 // --- D a t a --- |
2757 | 2771 |
2758 bool Value::FullIsUndefined() const { | 2772 bool Value::FullIsUndefined() const { |
2759 bool result = Utils::OpenHandle(this)->IsUndefined(); | 2773 bool result = Utils::OpenHandle(this)->IsUndefined(); |
2760 DCHECK_EQ(result, QuickIsUndefined()); | 2774 DCHECK_EQ(result, QuickIsUndefined()); |
2761 return result; | 2775 return result; |
2762 } | 2776 } |
2763 | 2777 |
2764 | 2778 |
(...skipping 6013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8778 Address callback_address = | 8792 Address callback_address = |
8779 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8793 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
8780 VMState<EXTERNAL> state(isolate); | 8794 VMState<EXTERNAL> state(isolate); |
8781 ExternalCallbackScope call_scope(isolate, callback_address); | 8795 ExternalCallbackScope call_scope(isolate, callback_address); |
8782 callback(info); | 8796 callback(info); |
8783 } | 8797 } |
8784 | 8798 |
8785 | 8799 |
8786 } // namespace internal | 8800 } // namespace internal |
8787 } // namespace v8 | 8801 } // namespace v8 |
OLD | NEW |