| OLD | NEW |
| 1 // Copyright 2007-2010 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2010 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 CHECK_EQ(make_code(BUILTIN, Builtins::kArrayCode), | 109 CHECK_EQ(make_code(BUILTIN, Builtins::kArrayCode), |
| 110 Encode(encoder, Builtins::kArrayCode)); | 110 Encode(encoder, Builtins::kArrayCode)); |
| 111 CHECK_EQ(make_code(v8::internal::RUNTIME_FUNCTION, Runtime::kAbort), | 111 CHECK_EQ(make_code(v8::internal::RUNTIME_FUNCTION, Runtime::kAbort), |
| 112 Encode(encoder, Runtime::kAbort)); | 112 Encode(encoder, Runtime::kAbort)); |
| 113 ExternalReference total_compile_size = | 113 ExternalReference total_compile_size = |
| 114 ExternalReference(isolate->counters()->total_compile_size()); | 114 ExternalReference(isolate->counters()->total_compile_size()); |
| 115 CHECK_EQ(make_code(STATS_COUNTER, Counters::k_total_compile_size), | 115 CHECK_EQ(make_code(STATS_COUNTER, Counters::k_total_compile_size), |
| 116 encoder.Encode(total_compile_size.address())); | 116 encoder.Encode(total_compile_size.address())); |
| 117 ExternalReference stack_limit_address = | 117 ExternalReference stack_limit_address = |
| 118 ExternalReference::address_of_stack_limit(isolate); | 118 ExternalReference::address_of_stack_limit(isolate); |
| 119 CHECK_EQ(make_code(UNCLASSIFIED, 4), | 119 CHECK_EQ(make_code(UNCLASSIFIED, 2), |
| 120 encoder.Encode(stack_limit_address.address())); | 120 encoder.Encode(stack_limit_address.address())); |
| 121 ExternalReference real_stack_limit_address = | 121 ExternalReference real_stack_limit_address = |
| 122 ExternalReference::address_of_real_stack_limit(isolate); | 122 ExternalReference::address_of_real_stack_limit(isolate); |
| 123 CHECK_EQ(make_code(UNCLASSIFIED, 5), | 123 CHECK_EQ(make_code(UNCLASSIFIED, 3), |
| 124 encoder.Encode(real_stack_limit_address.address())); | 124 encoder.Encode(real_stack_limit_address.address())); |
| 125 CHECK_EQ(make_code(UNCLASSIFIED, 16), | 125 CHECK_EQ(make_code(UNCLASSIFIED, 8), |
| 126 encoder.Encode(ExternalReference::debug_break(isolate).address())); | 126 encoder.Encode(ExternalReference::debug_break(isolate).address())); |
| 127 CHECK_EQ(make_code(UNCLASSIFIED, 10), | 127 CHECK_EQ( |
| 128 encoder.Encode( | 128 make_code(UNCLASSIFIED, 4), |
| 129 ExternalReference::new_space_start(isolate).address())); | 129 encoder.Encode(ExternalReference::new_space_start(isolate).address())); |
| 130 CHECK_EQ(make_code(UNCLASSIFIED, 3), | 130 CHECK_EQ( |
| 131 encoder.Encode( | 131 make_code(UNCLASSIFIED, 1), |
| 132 ExternalReference::roots_array_start(isolate).address())); | 132 encoder.Encode(ExternalReference::roots_array_start(isolate).address())); |
| 133 CHECK_EQ(make_code(UNCLASSIFIED, 52), | 133 CHECK_EQ(make_code(UNCLASSIFIED, 34), |
| 134 encoder.Encode(ExternalReference::cpu_features().address())); | 134 encoder.Encode(ExternalReference::cpu_features().address())); |
| 135 } | 135 } |
| 136 | 136 |
| 137 | 137 |
| 138 TEST(ExternalReferenceDecoder) { | 138 TEST(ExternalReferenceDecoder) { |
| 139 Isolate* isolate = CcTest::i_isolate(); | 139 Isolate* isolate = CcTest::i_isolate(); |
| 140 isolate->stats_table()->SetCounterFunction(counter_function); | 140 isolate->stats_table()->SetCounterFunction(counter_function); |
| 141 v8::V8::Initialize(); | 141 v8::V8::Initialize(); |
| 142 | 142 |
| 143 ExternalReferenceDecoder decoder(isolate); | 143 ExternalReferenceDecoder decoder(isolate); |
| 144 CHECK_EQ(AddressOf(Builtins::kArrayCode), | 144 CHECK_EQ(AddressOf(Builtins::kArrayCode), |
| 145 decoder.Decode(make_code(BUILTIN, Builtins::kArrayCode))); | 145 decoder.Decode(make_code(BUILTIN, Builtins::kArrayCode))); |
| 146 CHECK_EQ(AddressOf(Runtime::kAbort), | 146 CHECK_EQ(AddressOf(Runtime::kAbort), |
| 147 decoder.Decode(make_code(v8::internal::RUNTIME_FUNCTION, | 147 decoder.Decode(make_code(v8::internal::RUNTIME_FUNCTION, |
| 148 Runtime::kAbort))); | 148 Runtime::kAbort))); |
| 149 ExternalReference total_compile_size = | 149 ExternalReference total_compile_size = |
| 150 ExternalReference(isolate->counters()->total_compile_size()); | 150 ExternalReference(isolate->counters()->total_compile_size()); |
| 151 CHECK_EQ(total_compile_size.address(), | 151 CHECK_EQ(total_compile_size.address(), |
| 152 decoder.Decode( | 152 decoder.Decode( |
| 153 make_code(STATS_COUNTER, | 153 make_code(STATS_COUNTER, |
| 154 Counters::k_total_compile_size))); | 154 Counters::k_total_compile_size))); |
| 155 CHECK_EQ(ExternalReference::address_of_stack_limit(isolate).address(), | 155 CHECK_EQ(ExternalReference::address_of_stack_limit(isolate).address(), |
| 156 decoder.Decode(make_code(UNCLASSIFIED, 2))); |
| 157 CHECK_EQ(ExternalReference::address_of_real_stack_limit(isolate).address(), |
| 158 decoder.Decode(make_code(UNCLASSIFIED, 3))); |
| 159 CHECK_EQ(ExternalReference::debug_break(isolate).address(), |
| 160 decoder.Decode(make_code(UNCLASSIFIED, 8))); |
| 161 CHECK_EQ(ExternalReference::new_space_start(isolate).address(), |
| 156 decoder.Decode(make_code(UNCLASSIFIED, 4))); | 162 decoder.Decode(make_code(UNCLASSIFIED, 4))); |
| 157 CHECK_EQ(ExternalReference::address_of_real_stack_limit(isolate).address(), | |
| 158 decoder.Decode(make_code(UNCLASSIFIED, 5))); | |
| 159 CHECK_EQ(ExternalReference::debug_break(isolate).address(), | |
| 160 decoder.Decode(make_code(UNCLASSIFIED, 16))); | |
| 161 CHECK_EQ(ExternalReference::new_space_start(isolate).address(), | |
| 162 decoder.Decode(make_code(UNCLASSIFIED, 10))); | |
| 163 } | 163 } |
| 164 | 164 |
| 165 | 165 |
| 166 class FileByteSink : public SnapshotByteSink { | 166 class FileByteSink : public SnapshotByteSink { |
| 167 public: | 167 public: |
| 168 explicit FileByteSink(const char* snapshot_file) { | 168 explicit FileByteSink(const char* snapshot_file) { |
| 169 fp_ = v8::base::OS::FOpen(snapshot_file, "wb"); | 169 fp_ = v8::base::OS::FOpen(snapshot_file, "wb"); |
| 170 file_name_ = snapshot_file; | 170 file_name_ = snapshot_file; |
| 171 if (fp_ == NULL) { | 171 if (fp_ == NULL) { |
| 172 PrintF("Unable to write to snapshot file \"%s\"\n", snapshot_file); | 172 PrintF("Unable to write to snapshot file \"%s\"\n", snapshot_file); |
| (...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 837 { | 837 { |
| 838 DisallowCompilation no_compile(reinterpret_cast<Isolate*>(isolate2)); | 838 DisallowCompilation no_compile(reinterpret_cast<Isolate*>(isolate2)); |
| 839 script = v8::ScriptCompiler::CompileUnbound( | 839 script = v8::ScriptCompiler::CompileUnbound( |
| 840 isolate2, &source, v8::ScriptCompiler::kConsumeCodeCache); | 840 isolate2, &source, v8::ScriptCompiler::kConsumeCodeCache); |
| 841 } | 841 } |
| 842 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run(); | 842 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run(); |
| 843 CHECK(result->ToString()->Equals(v8_str("abcdef"))); | 843 CHECK(result->ToString()->Equals(v8_str("abcdef"))); |
| 844 } | 844 } |
| 845 isolate2->Dispose(); | 845 isolate2->Dispose(); |
| 846 } | 846 } |
| OLD | NEW |